Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: compile code eagerly in snapshot builder #51672

Merged
merged 1 commit into from
Feb 20, 2024

Commits on Feb 15, 2024

  1. src: compile code eagerly in snapshot builder

    By default V8 only compiles the top-level function and
    skips code generation for inner functions - that would
    only be done when those inner functions are invoked.
    Since builtins are compiled as wrapped functions, most
    functions that look visually top-level are not actually
    included in the built-in code cache. For most of the
    builtins this is not too bad because usually only a subset of
    all builtin functions are needed by a particular
    application and including all their code in the binary
    would incur an unnecessary size overhead. But there is also
    a subset of more commonly used builtins and it would be
    better to include the inner functions in the built-in
    code cache because they are more universally used by
    most applications.
    
    This patch changes the compilation strategy to eager compilation
    (including inner functions) for the following scripts:
    
    1. Primordials (internal/per_context/*), in all situations.
    2. Bootstrap scripts (internal/bootstrap/*) and main scripts
       (internal/main/*), when being compiled for built-in code
       cache.
    3. Any scripts loaded during built-in snapshot generation.
    
    We can't compile the code eagerly during snapshot generation
    and include them into the V8 snapshot itself just now because
    we need to start the inspector before context deserialization
    for coverage collection to work. So leave that as a TODO.
    
    With this patch the binary size increases by about 666KB
    (~0.6% increase) in return the worker startup can be 18-19% faster.
    joyeecheung committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    fff0dbd View commit details
    Browse the repository at this point in the history