Skip to content

feat(cache): expose configurable entry and byte budgets in v2 - #243

Merged
dperini merged 1 commit into
masterfrom
fix/v2-configurable-cache-budgets
Oct 10, 2026
Merged

dperini merged 1 commit into
masterfrom
fix/v2-configurable-cache-budgets

Conversation

@jdalton

@jdalton jdalton commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Expose numeric CACHE_LIMIT and CACHE_BYTES options through configure() in nwsapi 2.x.

  • Preserve the defaults of 1,000 entries and 2MiB per compiled-plan cache.
  • Accept nonnegative safe integers. Zero disables the applicable cache retention.
  • Validate numeric options before changing configuration and read accessor values once.
  • Clear and resize existing caches immediately when either budget changes.
  • Preserve Boolean options and the existing LRU eviction policy.
  • Document how a host can opt into larger bounded caches for a large stylesheet.

Related to #242. This is a mitigation when a stylesheet fits the configured bounds. It does not resolve LRU thrashing for scans larger than those bounds. The V3 admission-policy change is intentionally outside this PR.

Validation

  • 63 tests passed: the new cache configuration tests and existing fast-path integration tests.
  • Repeated with the branch's pinned jsdom 26.1.0 dependency, also 63 passed.
  • The 2,300 complex-selector reproduction retains its warmed selectors with 8,192 entries and an 8MiB budget.
  • Changed cache/configuration functions parse as ES5.
  • git diff --check passed.

No release or merge is included.

@dperini

dperini commented Oct 10, 2026

Copy link
Copy Markdown
Owner

@davidwilder
please check that this commit covers and fixes your needs.

@jdalton you are making the difference ... awesome.

@jdalton
jdalton deleted the fix/v2-configurable-cache-budgets branch October 21, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants