Visitar URL original
perf(javascript): halve the tokenizer cache tables · webpack/webpack@5038e64 · GitHub
Skip to content

Commit 5038e64

Browse files
perf(javascript): halve the tokenizer cache tables
4096 slots serve 96.4% of word lookups on large real sources versus 97.0% at 8192, while the always-allocated slot arrays and warm strings shrink by half or more during builds.
1 parent ebcd6a6 commit 5038e64

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎lib/javascript/syntax.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ const NO_CACHE = /** @type {EXPECTED_ANY} */ (null);
18631863
// by char compare, overwritten on collision. Shared across parses — hits are
18641864
// content-checked, so a stale entry is merely a miss. Only words short enough
18651865
// to be flat V8 strings (never slices retaining their whole source) are stored.
1866-
const WORD_CACHE_MASK = 0x1fff;
1866+
const WORD_CACHE_MASK = 0xfff;
18671867
/** @type {(string | null)[]} */
18681868
let WORD_CACHE = NO_CACHE;
18691869
const WORD_CACHE_MAX_LEN = 12;
@@ -1886,7 +1886,7 @@ let nextWordLookupsId = 1;
18861886
// too, so serving them from one shared string cuts both allocation churn and
18871887
// retained AST strings. Same rules as WORD_CACHE: content-checked hits, only
18881888
// lengths V8 stores flat (never slices retaining the source).
1889-
const SLICE_CACHE_MASK = 0x1fff;
1889+
const SLICE_CACHE_MASK = 0xfff;
18901890
/** @type {(string | null)[]} */
18911891
let SLICE_CACHE = NO_CACHE;
18921892
const SLICE_CACHE_MAX_LEN = 12;

0 commit comments

Comments
 (0)