Repository navigation
fix: keep css_data() stylesheets within vue_asset_max_bytes without a cache - #386
Merged
Merged
Conversation
JuroOravec
force-pushed
the
fix/css-data-bounded-store
branch
from
October 25, 2026 09:41
cbdb67f to
432e3fb
Compare
… cache Without a configured cache, every distinct css_data() result was written to the engine's default in-memory cache, which never drops anything, so values that change per request grew the process for its whole life. These stylesheets now live in the same per-process store as the compiled Vue assets and share its byte limit, which drops the ones used longest ago. A page publishes its stylesheets as it starts being written, while its Vue files are also protected from being dropped, so the Vue preparation, the dependencies step, an event response and a page serialized inside another one all find them, and the browser can fetch each one the page links. Inlining reads them from that store. A replayed render no longer writes its stylesheet to the default cache. With a configured cache, nothing changes: each render compares the stored stylesheet and writes it when it differs, and reads go to the backend. Fixes #154 Co-Authored-By: Claude Opus 5.5 <[email protected]>
JuroOravec
force-pushed
the
fix/css-data-bounded-store
branch
from
October 25, 2026 09:44
432e3fb to
ee5cb55
Compare
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.
Fixes #154. This is the second half; #366 was the first.
What changes
Without a configured cache, every distinct
css_data()result used to be written to the engine's default in-memory cache, which never drops anything. Values that change per request, such as a per-user color, grew the process for its whole life.As the maintainer decided in #154 (keep these stylesheets in the bounded per-process store):
css_data()stylesheets go into the same per-process store as the compiled Vue assets (_LocalAssetsin_vue/events.py). They share itsvue_asset_max_bytesbyte limit, and the ones used longest ago are dropped first.How a page keeps its own stylesheets:
hold_page_assets(citry, render, *, publish_css_data=True)is new. It keeps every file the page publishes from being dropped until the block ends, and on entry it publishes the render'scss_data()stylesheets (publish_css_data_stylesheetsinemission.py).serialize.pyenters it before the Vue preparation and the extensions'on_serialize. Preparing an event response enters it too, and so does a page serialized inside another page'son_serialize./cache/<class>.<hash>.csslink all find the stylesheet.deps_strategy="ignore"publish nothing.Other changes:
_RENDER_PUBLISHESis now a dict._enforce_limitreturns before walking the store when nothing is over the limit or nothing can be dropped. Writing a page with 8,000 distinct stylesheets takes about 0.12 s, the same as before this change, also with a 1-byte limit.Docs
vue_asset_max_bytesdocstring, thecache.pyandscripts.pymodule docstrings,docs_site/content/performance/cache-backends.md("Limit asset memory"),docs_site/content/advanced/web-frameworks.md("Share the cache") anddocs/design/dependencies.md(sections 4.2 and 10.1) now say that the limit covers these stylesheets.Left as it is:
Citry.clear()doesn't clear this process's store. That matches how it treats the Vue assets, and pages that are already open keep their files.Tests
New, in
tests/test_vue_asset_memory.py:on_serialize;New, in
tests/test_ext_cache_component.py: a cache hit without a configured cache keeps its stylesheet in memory only.Edited:
test_cache_hit_repairs_an_evicted_dependency_variable_stylesheetnow uses a configuredInMemoryCache. It checks that a replay writes the stylesheet back to the backend, and that write now happens only when a cache is configured.Two of the new tests fail on main: the byte-limit test and the replay test. The others pass on main because main keeps every stylesheet in a cache that never drops anything. They guard the new limit: each one fails against an earlier draft of this change that dropped a page's own stylesheets.
Evidence (local)
-m "not e2e") on origin/main 61ce8af: 9,762 passed, none failed.--platform linux), the protocol phases and the validators pass.PR CI runs the cargo phases and the full matrix.
🤖 Generated with Claude Code