Repository navigation
Conversation
✅ Deploy Preview for reselect-docs canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
maxSize: 2, calling a memoized function with(10, 1)and(11, 2)over three passes currently computes six times and returns new references. Each new primitive argument node consumes capacity, so generations rotate before two results fit. This change computes twice and preserves both references.Count each successfully cached or promoted argument tuple containing a primitive once per generation. Current-generation hits and failed calls do not consume capacity; separate tuples still count separately when
resultEqualityCheckreuses a result reference. Object-only calls continue to rely onWeakMapgarbage collection.Bounded caches publish new paths only after callbacks succeed, preventing failed calls from retaining primitive branches. Regression tests cover shared prefixes, reference stability, promotion and eviction, mixed object/primitive arguments and garbage collection,
maxSize: 1, clearing, exceptions, result equality, and reentrant callbacks. The default unbounded traversal stays separate to preserve its hot path.Validation on macOS arm64 with Node 24.22.1 and pnpm 11.23.0:
pnpm test: 162 runtime tests passed, with one existing skip and three existing todos; 29 type tests passed, plus the loose-null-checks compiler run.pnpm lint,pnpm format:check, andgit diff --checkpassed.pnpm buildpassed. Smoke checks passed for all five generated JavaScript bundles and both CJS entry modes; a consumer of the generated declarations compiled successfully.Paired local production benchmarks against the base branch found no confirmed slowdown in the tested default-path cases. Bounded-path microbenchmarks with matching computation counts measured approximately 14% slower single-primitive hits, 29–44% slower promotions, and 12–20% slower misses (roughly 2–24 ns per call on the test machine). These synthetic measurements capture the cost of deferred writes and are not application-level latency estimates.
Fixes #829