Skip to content

Consume compile hints in the new module registry - #8148

Open
floitsch wants to merge 1 commit into
mainfrom
floitsch/compile-hints-consume-new-registry
Open

floitsch wants to merge 1 commit into
mainfrom
floitsch/compile-hints-consume-new-registry

Conversation

@floitsch

@floitsch floitsch commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Bundle ES modules in the new module registry should eagerly compile the functions named by supplied compile hints when no code cache takes precedence. #7758 added this for the legacy registry; the new registry dropped WorkerSource::EsModule::compileHints when building module definitions and compiled without the V8 hint callback, so stored hints had no effect for Workers using new_module_registry.

Copy the hints into the shared module definition during registry construction and use the legacy registry’s sorted-position callback for bundle compilation. Owning the positions before the source bundle is released keeps them valid through lazy module resolution and across isolate replicas. The shared helper retains each registry’s existing compilation-error handling and reports consumption through the existing observer hook.

An installed isolate code cache keeps precedence on both misses and hits, and the shared module cache keeps precedence when no isolate store is installed. A hinted compilation can populate the shared cache for subsequent isolates. Hint production, added in #7917, still bypasses both caches and supplied hints so validation observes the functions that actually execute. Missing hints preserve ordinary compilation, and built-in modules do not consume bundle hints.

Copy WorkerSource hints into bundle module definitions and use the
shared V8 callback when compiling without a code cache. Keep installed
and shared code caches ahead of hints, and let hinted compilation
populate the shared cache for subsequent isolates.

Preserve producer precedence so validation observes executed functions
rather than supplied hints. Cover input ownership, both cache paths,
and Worker registry construction.
@floitsch
floitsch marked this pull request as ready for review November 2, 2026 15:49
@floitsch
floitsch requested review from a team as code owners November 2, 2026 15:49
@floitsch
floitsch requested a review from erikcorry November 2, 2026 15:49

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Approved with comments — The code change is correct and covered by tests. One INFO note: the documentation states the isolate-cache precedence more broadly than the code applies it.

Findings: 1 info

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📝 Documentation: 💬 1 info

The cache precedence statement is broader than the implementation.

Recommendation: 💬 Optional Nits

  • [INFO] The docs say an installed isolate code cache takes precedence, but getDescriptor() uses it only for modules with a codeCacheKey (modules-new.c++:250-255). Consider limiting the statement to keyed modules. (docs/reference/detail/new-module-registry.md:205)
View full review
  • docs/reference/detail/new-module-registry.md:205: The docs say an installed isolate code cache always takes precedence. In the code, EsModule::getDescriptor() uses the isolate cache only for modules that have a codeCacheKey (modules-new.c++:250-255). Modules without a key fall through to the shared cache or to hinted compilation even when an isolate cache is installed. Consider saying that this precedence applies to keyed modules.

✅ All other checks passed

🔒 Security: ✅ LGTM

No security issues. Compile hints are source positions only. The sorted lookup reads only the position values and never uses them to access the source buffer.


📖 AGENTS.md: ✅ LGTM

No issues found. The new comments and docs describe the current behaviour and follow the repository's comment guidelines.


📋 Code Quality: ✅ LGTM

The hint copies are owned by the module definition, so they outlive the source bundle. Cache precedence and producer precedence are preserved, and error handling stays the same in both registries.


⚡ Performance: ✅ LGTM

No performance concerns. Hints are copied once per module definition and are not used on code-cache paths.


Reviewed commit: ed597ac6

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.

1 participant