You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[dart2wasm] Avoid repeatedly allocating strings for the same json object keys
Most jsons have ascii strings as keys in json objects and very often
those keys are highly repetitive.
In previous CLs we started to compute the hash of the json object keys
eagerly, even before allocating the string.
We can take advantage of this now by using consulting a fixed-size
interning cache. The cost of this cache is
* Memory: It has max 512 entries and only contains one byte strings used
as keys in json (keys are usually very small).
* Lookup: Bitmask and lookup in array, length comparison (fails often if
keys are not the same), plus byte comparison (may often suceeed)
* Insert: Simply store into an array.
The benefit is that we are very likely to allocate a lot less string
objects for the keys. This will make data fit better in caches, will
make string equality checks (in map lookups) more often hit the
fast case (pointer equality) and reduce GC pressure.
Change-Id: Id8ed3a972a267dd0201383f8f51ed82758bc0e63
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409680
Reviewed-by: Ömer Ağacan <[email protected]>
Commit-Queue: Martin Kustermann <[email protected]>
0 commit comments