Commit message:
For static QualifiedNames, precompute the Bloom filter.
If the name is known in advance, e.g. xml_names::kLangAttr, there's no
point in dynamically trying to call LocalNameUpper() and meticulously
putting together the bits of a Bloom filter; we can just store those 32
bits directly along the QualifiedName. This reduces the code size for
calling FastHasAttribute() and related code against these known names.
(The APK size bot claims a small increase for unclear reasons, but a
large reduction on arm64, and we also wee a significant reduction just
building the binaries locally on x86-64 Linux.)
It would be even better to just have a compile-time constant
instead of loading it from RAM, but we don't have that kind of ambition
in this patch; it would require constexpr rapidhash, at the very least.
Note that HTMLQualifiedName (and also SVGQualifiedName etc.), which is
mostly a simple alias to increase type safety, now inherits from
HTMLQualifiedNameWithHash, since there's no point in having a variant
of these without the hash.
We currently hard-code an assumption that Element::TinyBloomFilter
is uint32_t, in order to not pull element.h into qualified_name.h.
Certain benchmarks look unfairly good with this presumably since
we move the work of creating the uppercased LocalName string to
the process initialization instead of the actual parse time.
It _is_ faster to do it once on a static buffer like we do here,
but it seems unlikely to actually speed up e.g. CSS parsing by 10%,
like the Search microbenchmark would suggest. To counteract this,
we run the style perftest with --gtest_repeat=10 so that also the
old version gets to do most of its runs using a warmed-up string
pool; yet, we get a small benefit in parsing.
Style perftest (Zen 3, LTO but no PGO):
Parse (µs) Before After Perf 95% CI (BCa)
=================== ========= ========= ======= =================
ECommerce 999 993 +0.6% [ -0.0%, +1.4%]
Encyclopedia 5405 5372 +0.6% [ +0.2%, +1.1%]
Extension 635 645 -1.5% [ -2.4%, -0.6%]
News 5919 5867 +0.9% [ +0.4%, +1.4%]
Search 3760 3697 +1.7% [ +0.8%, +3.1%]
Social1 10712 10651 +0.6% [ +0.1%, +1.0%]
Social2 472 465 +1.4% [ +0.6%, +2.2%]
Sports 41381 41007 +0.9% [ +0.3%, +1.6%]
Video 24636 24398 +1.0% [ -1.1%, +3.1%]
Geometric mean +0.7% [ +0.3%, +1.1%]
Speedometer3 is a bit up and down, but more up than down and those
that are down are just barely statistically significant
(M1 Pinpoint, lower is better, significant results at 99% CI only):
Charts-observable-plot [ +0.1%, +0.8%]
TodoMVC-WebComponents [ +0.1%, +0.8%]
NewsSite-Next [ +0.0%, +0.3%]
TodoMVC-JavaScript-ES5 [ -2.3%, -0.4%]
TodoMVC-JavaScript-ES6-Webpack-Complex-DOM [ -1.4%, -0.6%]