Amir Gonnen
5eb6daf9ed
py: Faster qstr search.
...
Pending upstream PR: https://github.com/micropython/micropython/pull/6896
This optimization is important because LVGL creates thousands
of qstrs and 'import' can take seconds instead of milliseconds without
better qstr search.
Currently this PR is pending. Once it is merged or some other
optimization that solves this problem is merged, this change
could be reverted and replaced by the upstream solution.
Today qstr implementation scans strings sequntially.
In cases there are many strings this can become very inefficient.
This change improves qstr search performance by using binary search in
sorted qstr pools, when possible.
This change introduces an option to create a sorted string pool, which
is then searched by a binary search instead of sequential search.
qstr pool can be either "sorted" or "unsorted", whereas the unsorted is
searched sequentally as today.
Native modules (MP_ROM_QSTR) and frozen modules generate sorted pools.
Currently runtime strings are unsorted.
The constant string pools is split into two and a new pool is introduced,
"special_const_pool". This is required because the first sequence of
strings already requires special ordering therefore created unsorted,
while the rest of the constants are generated sorted.
qstr_find_strn searches strings in each pool. If the pool is sorted and
larger than a threshold, it will be search using binary search instead
of sequential search, significantly improving performance.
(cherry picked from commit 8532c21c663e927d1a9974b75155e57b489a0d1e)
2021-02-27 02:14:36 +02:00
..
2020-04-05 15:02:06 +10:00
2020-06-27 00:24:04 +10:00
2020-06-27 00:24:04 +10:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2021-01-29 23:57:10 +11:00
2021-01-29 23:57:10 +11:00
2020-06-27 00:24:04 +10:00
2020-06-27 00:24:04 +10:00
2020-06-27 00:24:04 +10:00
2020-06-27 00:24:04 +10:00
2020-02-28 10:33:03 +11:00
2020-06-27 00:24:04 +10:00
2020-02-28 10:29:32 +11:00
2020-04-05 15:02:06 +10:00
2020-09-11 17:22:28 +10:00
2020-11-11 22:18:24 +11:00
2019-09-02 13:14:27 +10:00
2020-03-26 01:25:45 +11:00
2020-04-05 15:02:06 +10:00
2020-02-28 10:33:03 +11:00
2020-04-23 11:24:25 +10:00
2020-09-04 17:36:51 +03:00
2019-08-28 12:47:58 +10:00
2020-09-18 18:34:02 +10:00
2020-04-05 14:13:02 +10:00
2020-02-28 10:33:03 +11:00
2020-04-23 11:24:25 +10:00
2018-10-28 00:38:18 +11:00
2020-09-11 17:22:28 +10:00
2019-08-30 16:44:12 +10:00
2021-01-29 23:57:10 +11:00
2020-10-22 11:47:36 +02:00
2018-09-04 14:31:28 +10:00
2021-01-29 23:57:10 +11:00
2018-09-04 14:31:28 +10:00
2018-09-04 14:31:28 +10:00
2019-12-12 20:15:28 +11:00
2018-09-04 14:31:28 +10:00
2019-11-02 01:09:15 +02:00
2020-04-18 22:42:24 +10:00
2017-07-31 18:35:40 +10:00
2020-02-28 10:33:03 +11:00
2019-05-17 18:06:11 +10:00
2021-01-30 14:41:29 +11:00
2018-12-20 17:52:16 +11:00
2020-06-16 23:18:01 +10:00
2020-10-22 11:53:16 +02:00
2020-06-16 22:02:24 +10:00
2020-04-20 10:32:49 +10:00
2020-09-04 17:36:51 +03:00
2021-02-27 02:14:36 +02:00
2020-11-12 15:04:53 +11:00
2021-01-31 17:48:59 +01:00
2020-02-28 10:33:03 +11:00
2020-10-10 00:16:26 +11:00
2020-11-24 01:07:17 +11:00
2020-01-12 10:34:10 +11:00
2020-12-14 13:57:15 +11:00
2020-02-28 10:33:03 +11:00
2020-06-02 15:42:20 +10:00
2020-04-23 11:24:25 +10:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2020-04-27 23:58:46 +10:00
2020-12-14 13:30:56 +11:00
2020-04-05 15:02:06 +10:00
2020-04-05 15:02:06 +10:00
2020-05-28 10:02:14 +10:00
2020-04-05 15:02:06 +10:00
2020-04-23 11:24:25 +10:00
2021-02-03 00:59:07 +11:00
2018-05-01 15:53:25 +10:00
2020-09-18 17:20:34 +10:00
2020-12-07 23:32:06 +11:00
2020-02-28 10:33:03 +11:00
2017-07-31 18:35:40 +10:00
2020-09-04 17:36:51 +03:00
2020-02-28 10:33:03 +11:00
2020-11-11 22:18:24 +11:00
2020-03-11 14:34:40 +11:00
2020-04-18 22:36:14 +10:00
2020-05-14 21:48:05 +10:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:31:07 +11:00
2020-02-28 10:33:03 +11:00
2017-12-28 16:46:30 +11:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2020-06-27 01:03:10 +10:00
2020-10-10 00:16:26 +11:00
2020-04-18 22:42:19 +10:00
2020-09-25 12:23:11 +10:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2020-06-30 23:55:32 +10:00
2020-06-27 01:03:10 +10:00
2020-04-05 15:02:06 +10:00
2020-10-10 00:16:26 +11:00
2020-02-28 10:33:03 +11:00
2020-10-22 11:47:36 +02:00
2020-02-28 10:33:03 +11:00
2019-02-12 14:54:51 +11:00
2020-09-11 10:04:57 +10:00
2021-01-29 23:57:10 +11:00
2019-08-30 16:44:12 +10:00
2020-06-30 23:55:32 +10:00
2017-07-31 18:35:40 +10:00
2020-02-28 10:33:03 +11:00
2020-05-28 10:02:14 +10:00
2020-11-11 22:18:24 +11:00
2020-04-18 22:42:24 +10:00
2020-05-28 10:02:14 +10:00
2020-04-05 15:02:06 +10:00
2018-03-13 14:03:15 +11:00
2019-02-12 14:54:51 +11:00
2020-09-04 00:10:24 +10:00
2020-02-11 15:43:13 +11:00
2020-04-23 11:24:25 +10:00
2017-11-20 09:30:06 +02:00
2020-01-13 01:01:45 +11:00
2020-04-05 15:02:06 +10:00
2017-10-04 12:37:50 +11:00
2020-02-28 10:33:03 +11:00
2020-04-05 15:02:06 +10:00
2019-02-12 14:54:51 +11:00
2020-10-22 11:53:16 +02:00
2019-12-27 12:53:36 +11:00
2020-04-13 22:19:37 +10:00
2020-12-07 23:32:06 +11:00
2020-02-28 10:33:03 +11:00
2020-04-05 15:02:06 +10:00
2017-06-09 17:33:01 +03:00
2020-12-07 23:32:06 +11:00
2020-04-05 15:02:06 +10:00
2020-02-28 10:33:03 +11:00
2020-10-10 00:16:32 +11:00
2019-12-27 12:34:22 +11:00
2019-02-12 14:54:51 +11:00
2020-01-09 11:25:26 +11:00
2020-03-26 01:21:04 +11:00
2020-03-26 01:21:04 +11:00
2020-10-01 15:26:43 +10:00
2020-09-11 23:00:03 +10:00
2020-04-18 22:36:14 +10:00
2017-07-31 18:35:40 +10:00
2020-02-28 10:33:03 +11:00
2017-07-31 18:35:40 +10:00
2021-01-30 15:13:24 +11:00
2019-12-12 20:15:28 +11:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2021-02-05 00:40:29 +02:00
2020-02-28 10:33:03 +11:00
2020-02-28 10:33:03 +11:00
2021-02-27 02:14:36 +02:00
2021-02-27 02:14:36 +02:00
2020-02-28 10:31:07 +11:00
2020-02-28 10:33:03 +11:00
2017-03-14 11:52:05 +11:00
2020-02-28 10:33:03 +11:00
2017-07-31 18:35:40 +10:00
2019-11-21 12:04:53 +11:00
2020-06-05 14:04:20 +10:00
2019-12-12 20:15:28 +11:00
2017-12-05 00:38:41 +02:00
2020-09-04 17:36:51 +03:00
2020-05-08 23:20:45 +10:00
2020-05-08 23:20:45 +10:00
2020-10-22 11:40:56 +02:00
2020-10-22 11:40:56 +02:00
2020-04-05 15:02:06 +10:00
2020-09-11 17:22:28 +10:00
2017-07-31 18:35:40 +10:00
2017-12-11 22:39:12 +11:00
2020-02-28 10:33:03 +11:00
2017-07-31 18:35:40 +10:00
2020-04-27 23:58:46 +10:00
2020-03-25 01:00:52 +11:00
2020-02-28 10:33:03 +11:00
2017-09-06 16:43:09 +10:00
2020-09-11 17:22:28 +10:00
2020-10-22 11:47:36 +02:00
2020-02-28 10:33:03 +11:00
2019-02-06 00:19:00 +11:00