From 5248b2567b9f627097ad25afd9671da9c9997224 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 24 May 2022 13:55:17 -0600 Subject: [PATCH] [ot-font/h-advance] Adjust varStore cache condition This gives best performance for short strings, now that we have a h-advance cache as well. The en-words benchmark in particular, now ot-font is faster than ft. Second to last line is of interest: Before: ----------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------------------------------------------------------- BM_Shape/en-words.txt/Roboto-Regular.ttf/hb 29.8 ms 29.8 ms 23 BM_Shape/en-words.txt/Roboto-Regular.ttf/ft 30.4 ms 30.4 ms 23 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/hb 16.3 ms 16.3 ms 43 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/ft 16.5 ms 16.5 ms 42 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/hb 18.0 ms 18.0 ms 39 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/ft 17.8 ms 17.8 ms 39 After: behdad@Behdads-MacBook-Pro harfbuzz % ninja -Cbuild && build/perf/benchmark-shape --benchmark_filter=en-words ----------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------------------------------------------------------- BM_Shape/en-words.txt/Roboto-Regular.ttf/hb 30.0 ms 30.0 ms 23 BM_Shape/en-words.txt/Roboto-Regular.ttf/ft 30.3 ms 30.3 ms 23 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/hb 16.3 ms 16.3 ms 43 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/ft 16.4 ms 16.4 ms 43 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/hb 17.6 ms 17.6 ms 40 BM_Shape/en-words.txt/SourceSerifVariable-Roman.ttf/var/ft 17.8 ms 17.8 ms 39 --- src/hb-ot-font.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 4b25db64a..d1032068b 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -153,7 +153,7 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, #ifndef HB_NO_VAR const OT::HVARVVAR &HVAR = *hmtx.var_table; const OT::VariationStore &varStore = &HVAR + HVAR.varStore; - OT::VariationStore::cache_t *varStore_cache = font->num_coords ? varStore.create_cache () : nullptr; + OT::VariationStore::cache_t *varStore_cache = font->num_coords * count >= 128 ? varStore.create_cache () : nullptr; bool use_cache = font->num_coords; #else