Commit Graph

13132 Commits

Author SHA1 Message Date
Behdad Esfahbod 407a135baf [perf/benchmark-ot] Add one more test 2022-05-17 14:45:45 -06:00
Behdad Esfahbod dd3c858f84 [ot-tags] Speed up hb_ot_tags_from_language()
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

"After that, bulk of the time I suppose is spent in binary-searching the
language table. I suggest we split the language table in 2-letter and
3-letter tags, to speed-up the vast majority of cases that are
2-letter."

benchmark-ot, before:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN        112 ns          111 ns      6286271
BM_hb_ot_tags_from_script_and_language/COMMON en_US       60.6 ns         60.4 ns     11671176
BM_hb_ot_tags_from_script_and_language/LATIN en_US        61.3 ns         61.1 ns     11442645
BM_hb_ot_tags_from_script_and_language/COMMON none        4.75 ns         4.74 ns    146997235
BM_hb_ot_tags_from_script_and_language/LATIN none         4.65 ns         4.64 ns    150938747

After:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN       89.5 ns         89.2 ns      7747649
BM_hb_ot_tags_from_script_and_language/COMMON en_US       38.5 ns         38.4 ns     18199432
BM_hb_ot_tags_from_script_and_language/LATIN en_US        39.0 ns         38.9 ns     18049238
BM_hb_ot_tags_from_script_and_language/COMMON none        4.53 ns         4.52 ns    154895110
BM_hb_ot_tags_from_script_and_language/LATIN none         4.54 ns         4.52 ns    154762105
2022-05-17 14:28:28 -06:00
Behdad Esfahbod 9baccb9860 [ot-tags] Speed up hb_ot_tags_from_complex_language()
Part of https://github.com/harfbuzz/harfbuzz/issues/3591

2. All the subtag_matches outside the switch match long strings (>= 6 or so).
   As such, check the tag for such length before going into any of them.

benchmark-ot, before:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN        172 ns          171 ns      4083155
BM_hb_ot_tags_from_script_and_language/COMMON en_US        120 ns          119 ns      5849947
BM_hb_ot_tags_from_script_and_language/LATIN en_US         113 ns          112 ns      5840326
BM_hb_ot_tags_from_script_and_language/COMMON none        4.66 ns         4.64 ns    151396224
BM_hb_ot_tags_from_script_and_language/LATIN none         4.66 ns         4.64 ns    149019593

After:

----------------------------------------------------------------------------------------------
Benchmark                                                    Time             CPU   Iterations
----------------------------------------------------------------------------------------------
BM_hb_ot_tags_from_script_and_language/COMMON zh_CN        112 ns          112 ns      6357763
BM_hb_ot_tags_from_script_and_language/COMMON en_US       60.5 ns         60.3 ns     11475091
BM_hb_ot_tags_from_script_and_language/LATIN en_US        54.9 ns         54.8 ns     12575690
BM_hb_ot_tags_from_script_and_language/COMMON none        4.61 ns         4.59 ns    152388450
BM_hb_ot_tags_from_script_and_language/LATIN none         4.66 ns         4.64 ns    151497600
2022-05-17 13:34:34 -06:00
Behdad Esfahbod 26d906b88b [perf] Add benchmark-ot 2022-05-17 13:12:17 -06:00
Behdad Esfahbod 629fa8ee87 [perf/benchmark-font] Test Roboto as variable even though it's not 2022-05-16 17:49:36 -06:00
Behdad Esfahbod 71a0cda869 [perf/benchmark-font] Only certain fonts are variable
Don't test every font as variable.
2022-05-16 17:49:36 -06:00
Behdad Esfahbod fb413f5202 [subset/cff] Don't use bitfields for hot bools
The struct has room because of alignment, and these bools are hot.
2022-05-16 17:38:18 -06:00
Behdad Esfahbod a4d98b63ea [subset/cff1] Collect glyph-to-sid map to avoid an O(n^2) algorithm
Saves 13 for largest benchmark:

BM_subset/subset_glyphs/SourceHanSans-Regular_subset.otf/10000                    -0.1313         -0.1308            75            65            75            65

BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/4096                 -0.1009         -0.1004            54            48            54            48
BM_subset/subset_codepoints/SourceHanSans-Regular_subset.otf/10000                -0.1067         -0.1066            70            62            69            62
2022-05-16 17:38:18 -06:00
Behdad Esfahbod b87f48e948 [cff1] get_sid() move bounds check into each implementation 2022-05-16 17:38:18 -06:00
Behdad Esfahbod e1e359b4da [cff1] Tighten up range_list_t a bit 2022-05-16 16:36:28 -06:00
Behdad Esfahbod 3fbac0942d [cff1] Lazy-load & sort glyph names
Improves subset benchmarks by up to 70% for small CFF1 subset of
non-CID fonts!

BM_subset/subset_glyphs/SourceSansPro-Regular.otf/10                              -0.7067         -0.7071             1             0             1             0
BM_subset/subset_glyphs/SourceSansPro-Regular.otf/64                              -0.4817         -0.4824             1             0             1             0
BM_subset/subset_glyphs/SourceSansPro-Regular.otf/512                             -0.1948         -0.1956             2             2             2             2
BM_subset/subset_glyphs/SourceSansPro-Regular.otf/2000                            -0.0767         -0.0761             6             6             6             6
2022-05-16 16:36:28 -06:00
Behdad Esfahbod b58bfd9818 [font] Minor move of code to silence gcc-12 warning
See mailing list discussion.
2022-05-16 11:21:45 -06:00
Behdad Esfahbod 602e0ca79d [cff] Minor restructure of struct
Surprisingly this shows tiny benchmark improvement consistently.
2022-05-16 10:14:34 -06:00
Behdad Esfahbod acdab17ed3 [cff] Cosmetic in parsed_values_t 2022-05-13 14:14:36 -06:00
Behdad Esfahbod b46c7faa9c [cff] Check buf_len, not buf
Ouch!
2022-05-13 14:02:54 -06:00
Garret Rieger 19a8db8545 [subset] fix potential integer overflow in gname_t::cmp. 2022-05-13 13:55:39 -06:00
Behdad Esfahbod 2d2f66e1a3 [cff-common] In INDEX, return empty bytes if length is zero
Before it was possible to return non-null arrayZ.
2022-05-13 13:53:17 -06:00
Behdad Esfahbod a2f132f1fc [cff] Check glyph-name's length, not arrayZ
As the latter can be non-null while still zero-length.
2022-05-13 13:49:39 -06:00
jeremiazhao dc09053f19 fix build requirements for fedora/centos in buiding document 2022-05-13 13:10:11 -06:00
Thomas Devoogdt c657c4e1f8 [meta] fix type traits on gcc 4.9 #3526
Signed-off-by: Thomas Devoogdt <thomas.devoogdt@barco.com>
2022-05-13 11:26:12 -06:00
Garret Rieger e4e053c8b3 [perf] fix typo in perf Makefile. 2022-05-13 11:25:09 -06:00
Behdad Esfahbod e61234c5f7 [vector] Add tests for move constructor/assignment 2022-05-12 13:20:10 -06:00
Behdad Esfahbod 7fa580bc4f [map] Fix map copy/move constructors to actually work
Ouch!
2022-05-12 13:05:32 -06:00
Behdad Esfahbod a09dd87ca3 [set] Fix set copy/move constructors to actually work
Ouch!
2022-05-12 12:58:07 -06:00
Behdad Esfahbod 76fc27713f [vector] Remove explicit std::move
Was confusing compilers. Let them figure it out themselves.

Makes NotoNastaliqu subsetting/1000 benchmark more than twice faster:

Benchmark                                                                       Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------------------------
BM_subset/subset_glyphs/NotoNastaliqUrdu-Regular.ttf/1000                    -0.5064         -0.5065           111            55           110            55
BM_subset/subset_codepoints/NotoNastaliqUrdu-Regular.ttf/1000                -0.5494         -0.5493           132            59           131            59
2022-05-12 12:14:07 -06:00
Behdad Esfahbod c81198b5bc [set] Tweak move operators a bit
Should be equivalent.
2022-05-12 12:14:02 -06:00
Behdad Esfahbod 8dc072d20d
Merge pull request #3579 from harfbuzz/subset-retain-buffer
Subset retain buffer
2022-05-11 16:45:40 -06:00
Behdad Esfahbod 175319cd89 [gsubgpos] Clean up OT::ClassDefFormat2::intersected_class_glyphs 0 case 2022-05-11 13:47:17 -06:00
Behdad Esfahbod 137af3612b [gsubgpos] Simplify OT::ClassDefFormat2::intersected_class_glyphs() 2022-05-11 13:39:30 -06:00
Behdad Esfahbod 3261e05bdb [subset] Optimize ClassDef1::intersected_class_glyphs() for class0 2022-05-11 13:16:31 -06:00
Behdad Esfahbod c78d8ba60b [subset] Allocate same size as source table for GSUB/GPOS/name 2022-05-11 13:05:41 -06:00
Behdad Esfahbod 2e7f1ae48f [subset] Use vector.allocated size instead of tracking buf_size 2022-05-11 12:52:27 -06:00
Behdad Esfahbod f08537963b [cff-subset] Pre-alloc vector for operator decoding 2022-05-11 12:14:49 -06:00
Behdad Esfahbod 7edd54f3dd [perf/benchmark-subset] Minor cleanup 2022-05-11 12:14:49 -06:00
Behdad Esfahbod aeb50b8942 [subset] Retain buffer across table subset operations 2022-05-11 12:14:49 -06:00
Behdad Esfahbod bff78e6515 [cff] Convert interpretation environment to use constructor 2022-05-10 16:50:38 -06:00
Behdad Esfahbod de053e2efb [cff] Convert subr_subset_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 96140db485 [cff] Convert cff2_extents_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 54544f2a57 [cff] Convert cff1_extents_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 377befd0c7 [cff] Convert get_seac_param_t to use constructor 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 8fd70362fa [cff] Use hb_ubytes_t() instead of Null(hb_ubytes_t) 2022-05-10 16:17:20 -06:00
Behdad Esfahbod 9033c7f99d [cff-common] Optimize INDEX::operator[]
Previous try showed slowdown in benchmarks, suprisingly.

Rewrite it keeping the function, hopefully allowing better optimization.
2022-05-10 14:58:53 -06:00
Behdad Esfahbod 3aace2431b Revert "[cff-common] Optimize INDEX::operator[]"
This reverts commit 9edb03ac7a.
2022-05-10 14:54:04 -06:00
Behdad Esfahbod b31ef081db Revert "[cff] Add an unlikely()"
This reverts commit 9ba9adb7ed.

This shows slowdown in benchmarks.
2022-05-10 14:52:40 -06:00
Behdad Esfahbod 9ba9adb7ed [cff] Add an unlikely() 2022-05-10 14:43:00 -06:00
Behdad Esfahbod 9edb03ac7a [cff-common] Optimize INDEX::operator[] 2022-05-10 14:43:00 -06:00
Garret Rieger 52d59bf150 [perf] Make subset benchmark data driven. 2022-05-10 14:30:08 -06:00
Behdad Esfahbod 0a42410dc8 [cff2] Change extents/shape stack to be just a number
Do the blending immediately.

Fixes https://github.com/harfbuzz/harfbuzz/issues/3559

Benchmark on AdobeVFPrototype shows 35% speedup. Now we're faster
than FreeType:

Benchmark                                                           Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------------
BM_Font/glyph_extents/AdobeVFPrototype.otf/hb                    -0.3792         -0.3792          1584           983          1581           982
BM_Font/glyph_extents/AdobeVFPrototype.otf/ft                    +0.0228         +0.0224          1220          1248          1218          1245
BM_Font/glyph_extents/AdobeVFPrototype.otf/var/hb                -0.3513         -0.3518          1616          1048          1613          1046
BM_Font/glyph_extents/AdobeVFPrototype.otf/var/ft                +0.0172         +0.0169          1232          1254          1230          1251
2022-05-10 13:41:12 -06:00
Garret Rieger 5277a5772b [perf] Add benchmarks for CFF subsetting. 2022-05-10 12:16:44 -06:00
Garret Rieger 8f9f0c494b [subset] Enforce cmap12 group ordering constraints in collect_mapping.
Fixes fuzzer issue: https://oss-fuzz.com/testcase-detail/6365271012540416
2022-05-10 12:15:09 -06:00