Commit Graph

13038 Commits

Author SHA1 Message Date
Behdad Esfahbod 14a24d8e3f [vector] Make hb_vector_t hashable 2022-05-19 13:04:06 -06:00
Behdad Esfahbod 124f9aeb9b [set] Make hb_set_t hashable 2022-05-19 12:58:02 -06:00
Garret Rieger 3ab2c7935f [subset-perf] Signficiantly speed up ClassDef*::subset.
Eliminates the usage of a glyph -> klass hash map and replaces it with a vector storing the mapping. This allows us to use the vector directly as the iterator driving the serialize. Approximately 1% speedup for Noto Nastaliq.
2022-05-19 12:37:28 -06:00
David Corbett e3e685e5ee [ot-tags] Fix `min_subtag_len` calculations 2022-05-18 18:30:01 -06:00
Garret Rieger 0b1c2ff96a [subset-perf] Remove extra map lookup in ClassDef subset methods. 2022-05-18 18:25:36 -06:00
Garret Rieger 13ace77f1d [subset-perf] Use glyph_map instead of set in ClassDefFormat. 2022-05-18 18:25:36 -06:00
Garret Rieger adae2f2272 [subset-perf] Cache a glyph map for gsub.
This allows us in some cases to avoid using glyph_set_gsub as a filter.
2022-05-18 18:25:36 -06:00
Behdad Esfahbod 202e6c4699 [subset] Remove unnecessary test 2022-05-18 17:12:43 -06:00
Behdad Esfahbod cedf739646 Add some commented-out code 2022-05-18 16:53:26 -06:00
Behdad Esfahbod 6b62c10f02 [priority-queue] Remove old init/fini 2022-05-18 16:27:54 -06:00
Behdad Esfahbod bff8248a9d [repacker] Pre-alloc vertices 2022-05-18 16:25:03 -06:00
Behdad Esfahbod 39a424caf0 [priority-queue] Optimize heap access 2022-05-18 16:19:44 -06:00
Behdad Esfahbod 9308659fd7 [priority-queue] Optimize swap() 2022-05-18 16:14:25 -06:00
Behdad Esfahbod c7317ef761 [repacker] Avoid destroying and recreating objects 2022-05-18 16:03:41 -06:00
Behdad Esfahbod 864e09a0c4 [repacker] Reuse allocated vector 2022-05-18 15:59:29 -06:00
Behdad Esfahbod ca77f16470 [repacker] Remove unnecessary vector .fini() calls 2022-05-18 15:55:49 -06:00
Behdad Esfahbod 4cfc2d668e [subset] Use a std::move on set_t when feasible 2022-05-18 15:32:19 -06:00
Behdad Esfahbod 1f578b5a32 [set] Add pre-allocation internal API 2022-05-18 15:25:00 -06:00
Garret Rieger 48dfbd54a3 [subset] minor cleanup. 2022-05-18 15:24:54 -06:00
Garret Rieger 482c6e5dc4 [subset-perf] Speed up Coverage::serialize by caching iterator. 2022-05-18 15:24:54 -06:00
Behdad Esfahbod 14b18725f0 In Coverage::iter_t, assume iterators are from same Coverage object
No need to support otherwise.
2022-05-18 15:14:32 -06:00
Behdad Esfahbod 27141735c3 [subset] Add Coverage::__end__ implementation 2022-05-18 15:12:49 -06:00
Behdad Esfahbod c476f58adb [subset] Write CoverageFormat2::intersects_coverage() as bsearch() 2022-05-18 14:20:23 -06:00
Behdad Esfahbod 63c6695108 [ot-layout] Cosmetic
The implementation of HBUINT16 operator == is slower than just
comparing to ints.
2022-05-18 13:53:52 -06:00
Behdad Esfahbod 777debd748 [subset] Rewrite CoverageFormat2::intersects as dagger 2022-05-18 13:46:06 -06:00
Behdad Esfahbod cf5001fac7 [subset] Optimize CoverageFormat2::intersected_coverage_glyphs 2022-05-18 13:38:29 -06:00
Behdad Esfahbod 6f37c20798 [subset] Minor rewrite in CoverageFormat2::serialize() 2022-05-18 13:25:42 -06:00
Behdad Esfahbod e91863b717 [subset-cff] Pre-size map in subr_remap_t::create() 2022-05-18 12:39:55 -06:00
Behdad Esfahbod ce60462173 [subset-plan] Pre-size maps in _create_old_gid_to_new_gid_map() 2022-05-18 12:34:27 -06:00
Behdad Esfahbod f82ee17a75 [map] Pre-size map in constructor if we can 2022-05-18 12:19:49 -06:00
Behdad Esfahbod b5aa8a27ea [subset-cff] Cosmetic 2022-05-18 11:58:58 -06:00
Behdad Esfahbod 0b201623f5 [subset-cff] Fix previous commit
Oops!
2022-05-18 11:58:22 -06:00
Behdad Esfahbod 4792309265 [subset-cff] Access vector directly 2022-05-18 11:54:08 -06:00
Behdad Esfahbod 7c86f2e763 [subset-cff] Pre-alloc out buffer 2022-05-18 11:45:27 -06:00
Behdad Esfahbod 0761e7cdfd [subset-cff] Avoid resetting buffer as encoder does 2022-05-18 11:38:25 -06:00
Behdad Esfahbod 71aa10a394 [subset-cff] Manually grow vector to avoid memset overhead 2022-05-18 11:37:24 -06:00
Behdad Esfahbod f455cc53fd [subset-cff] Reuse buffer allocation 2022-05-18 11:31:55 -06:00
Behdad Esfahbod 3e4ab2ad9c [perf/benchmark-ot] Add zh-hans 2022-05-18 11:16:46 -06:00
Behdad Esfahbod 6e668a2ade [perf/benchmark-ot] Rename test 2022-05-18 11:16:11 -06:00
Behdad Esfahbod e24797aeac [ot-tags] Follow-up to previous commit
Part of https://github.com/harfbuzz/harfbuzz/issues/3591
2022-05-18 11:10:10 -06:00
Behdad Esfahbod f5d619be79 [ot-tags] Further gate the slow complex case, and add more tests
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

Still 'zh-trad' is the slowest case.

--------------------------------------------------------------------------------------------------
Benchmark                                                        Time             CPU   Iterations
--------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_trad          136 ns          136 ns      5107838
BM_hb_ot_tags_from_script_and_language/COMMON ab_abcd          115 ns          115 ns      6103104
BM_hb_ot_tags_from_script_and_language/COMMON ab_abc          25.4 ns         25.3 ns     27674482
BM_hb_ot_tags_from_script_and_language/COMMON abcdef_XY       20.2 ns         20.1 ns     34795719
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY         19.4 ns         19.3 ns     36390401
BM_hb_ot_tags_from_script_and_language/COMMON cxy_CN          33.5 ns         33.4 ns     20998939
BM_hb_ot_tags_from_script_and_language/COMMON exy_CN          25.1 ns         25.0 ns     27705832
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN           34.2 ns         34.1 ns     20564356
BM_hb_ot_tags_from_script_and_language/COMMON en_US           15.5 ns         15.5 ns     45032204
BM_hb_ot_tags_from_script_and_language/LATIN en_US            15.9 ns         15.8 ns     44412379
BM_hb_ot_tags_from_script_and_language/COMMON none            4.72 ns         4.71 ns    149101665
BM_hb_ot_tags_from_script_and_language/LATIN none             4.72 ns         4.70 ns    149254498
2022-05-18 11:04:52 -06:00
Behdad Esfahbod 9c64bda21d [ot-tag] Whitespace 2022-05-17 17:31:18 -06:00
Behdad Esfahbod 3df8017e9b [ot-tag] Optimize subtag_matches() more 2022-05-17 17:29:39 -06:00
Behdad Esfahbod b231fc2dbc [perf/benchmark-ot] Add a couple more test cases 2022-05-17 17:03:37 -06:00
Behdad Esfahbod 3524b14fa0 [perf/benchmark-ot] Add a couple more test cases 2022-05-17 17:02:48 -06:00
Behdad Esfahbod 7f6e8c5536 [ot-tags] Optimize subtag_matches() further
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

Comparing before to after
Benchmark                                                               Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY                -0.3371         -0.3371            71            47            71            47
2022-05-17 16:58:35 -06:00
Behdad Esfahbod 27c11405a2 [ot-tag] Optimize subtag_matches
Part of https://github.com/harfbuzz/harfbuzz/issues/3591
2022-05-17 16:51:51 -06:00
Behdad Esfahbod a07d818597 [ot-tag] Add a likely() to the cache hit case 2022-05-17 16:46:10 -06:00
Behdad Esfahbod 0ff5d36cd4 [perf/benchmark-ot] Fix benchmark
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

Ouch!

These are the current numbers:

------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       78.0 ns         77.7 ns      8917912
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         44.9 ns         44.8 ns     15475318
BM_hb_ot_tags_from_script_and_language/COMMON en_US         17.6 ns         17.5 ns     39812340
BM_hb_ot_tags_from_script_and_language/LATIN en_US          18.2 ns         18.1 ns     38356204
BM_hb_ot_tags_from_script_and_language/COMMON none          4.76 ns         4.74 ns    148746131
BM_hb_ot_tags_from_script_and_language/LATIN none           4.73 ns         4.71 ns    148421349
2022-05-17 16:38:19 -06:00
Behdad Esfahbod dfca47f419 [ot-tag] Cache last bsearch result
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

Humm. Looks like not all of the fat is bsearch overhead now. I cached
the last bsearch result, but most of the time is still there. I'm
baffled.

Before:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.08 ns         8.05 ns     84500482
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         42.2 ns         42.1 ns     16722006
BM_hb_ot_tags_from_script_and_language/COMMON en_US         16.1 ns         16.0 ns     43461527
BM_hb_ot_tags_from_script_and_language/LATIN en_US          16.5 ns         16.5 ns     42448505
BM_hb_ot_tags_from_script_and_language/COMMON none          4.34 ns         4.33 ns    161290530
BM_hb_ot_tags_from_script_and_language/LATIN none           4.34 ns         4.33 ns    162339799

After:
------------------------------------------------------------------------------------------------
Benchmark                                                      Time             CPU   Iterations
------------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON abcd_XY       8.13 ns         8.11 ns     80438134
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN         40.0 ns         39.9 ns     17487939
BM_hb_ot_tags_from_script_and_language/COMMON en_US         12.7 ns         12.7 ns     55124394
BM_hb_ot_tags_from_script_and_language/LATIN en_US          13.1 ns         13.0 ns     53660125
BM_hb_ot_tags_from_script_and_language/COMMON none          4.61 ns         4.60 ns    151394104
BM_hb_ot_tags_from_script_and_language/LATIN none           4.70 ns         4.68 ns    150402847
2022-05-17 16:21:02 -06:00