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

build: speed up startup with V8 code cache #21405

Closed
wants to merge 5 commits into from

Commits on Jun 25, 2018

  1. build: speed up startup with V8 code cache

    This patch speeds up the startup time and reduce the startup memory
    footprint by using V8 code cache when comiling builtin modules.
    
    The current approach is demonstrated in the `with-code-cache`
    Makefile target (no corresponding Windows target at the moment).
    
    1. Build the binary normally (`src/node_code_cache_stub.cc` is used),
      by now `internalBinding('code_cache')` is an empty object
    2. Run `tools/generate_code_cache.js` with the binary, which generates
      the code caches by reading source code of builtin modules off source
      code exposed by `require('internal/bootstrap/cache').builtinSource`
      and then generate a C++ file containing static char arrays of the
      code cache, using a format similar to `node_javascript.cc`
    3. Run `configure` with the `--code-cache-path` option so that
      the newly generated C++ file will be used when compiling the
      new binary. The generated C++ file will put the cache into
      the `internalBinding('code_cache')` object with the module
      ids as keys
    4. The new binary tries to read the code cache from
      `internalBinding('code_cache')` and use it to compile
      builtin modules. If the cache is used, it will put the id
      into `require('internal/bootstrap/cache').compiledWithCache`
      for bookkeeping, otherwise the id will be pushed into
      `require('internal/bootstrap/cache').compiledWithoutCache`
    
    This patch also added tests that verify the code cache is
    generated and used when compiling builtin modules.
    
    The binary with code cache:
    
    - Is ~1MB bigger than the binary without code cahe
    - Consumes ~1MB less memory during start up
    - Starts up about 60% faster
    joyeecheung committed Jun 25, 2018
    Configuration menu
    Copy the full SHA
    005a274 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    30a3827 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4cca13e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    29cc730 View commit details
    Browse the repository at this point in the history

Commits on Jun 26, 2018

  1. Configuration menu
    Copy the full SHA
    7c4b001 View commit details
    Browse the repository at this point in the history