Repository navigation
perf: inline first context provider cache entry - #1019
Merged
domgan-oai merged 1 commit intoSep 9, 2026
Merged
Conversation
domgan-oai
marked this pull request as ready for review
September 9, 2026 16:10
Closed
68 of 84 tasks
14 of 21 tasks
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.
Summary
undefined, default-context reads, hosted owner activation/rebind, conditional reads, and remounts.has/getwork remains open.Validation
pnpm format:check(scopedpnpm format:files:checkpassed for every changed path)pnpm typecheckpnpm testlocally (160 targeted context, host-bridge, JSX, manual-hook, and hydration tests passed in dev and prod compile modes; the full suite passed in current-head CI)pnpm sync(no unrelated tracked diff)node benchmarks/recursive-context/context-cache-work.mjs(production Chromium; baseline/current Map constructions for 512 keyed rows: zero 6/6, one 518/6, two 518/518; update, reorder, and teardown counts unchanged; DOM/identity controls pass)21ae658a1(attempt 2 after a Vitest worker failed to run an unrelated SliderTrack test on attempt 1; that file passed locally 30/30). Bugbot passed.Risk / follow-ups
Map.has+Map.getprobes remain a separate item; changing their order can add probes to deep misses.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Medium Risk
Touches core
readContextFrom/ context caching on everyuse()call and adds a new pointer field on all scopes; behavior is heavily gated but incorrect cache semantics would surface as stale or wrong context values.Overview
Octane’s
use()resolved-provider cache no longer allocates aMapon every consumer’s first context read. The first context key and its provider owner are stored inline onScope/Block($$ctxCache+$$ctxCacheOwner); aMapis created only when that consumer reads a second distinct context. Cached entries still point at the owning scope (or the default/bridge sentinel), so values stay live across provider updates,undefined, hosted-owner rebinds, and remounts—hosted roots now drop the cache on rebind instead of callingMap.clear().Benchmarking and CI gates: the recursive-context suite adds a production Chromium work pass (
context-cache-work.mjs,bench:cache) with 512 keyed rows in zero/one/two-context modes. It countsMapconstructions (expect 0 extra Maps for single-context mount vs control, 512 for two-context spill) and checks DOM/identity on update, secondary provider, reorder, and unmount;work.mjsruns this after precise coverage.Tests extend context and react-hosted coverage for multi-context updates, conditional second reads, optional
undefined, full root remount, and owner rebinding on a retained root.Reviewed by Cursor Bugbot for commit 21ae658. Bugbot is set up for automated code reviews on this repo. Configure here.