jcrist · GitHub

@jcrist

This adds a cache for ascii string dict keys for the JSON decoder only.
Since most JSON objects are structured (with repeated keys), this helps
improve performance by reusing the same string key objects multiple
times. This slightly reduces performance for cases where string keys
don't repeat (cache is overhead only), but can result in up to 40%
speedup in cases where the cache is hit. Using a cached string:
- Removes the cost of string validation and allocation
- Reduces memory usage by reusing objects
- Removes the need for a siphash24 call, since string hashes are cached
on the string object itself.
The cache is cleared currently every 10 major GC passes to periodically
free up old pages and reduce fragmentation.

Read the original on github.com ↗