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: stop copying code cache #47144

Merged
merged 5 commits into from
May 7, 2023
Merged

Commits on Apr 10, 2023

  1. src: stop copying code cache

    The code cache is quite large - around 1.3 MiB. Change the code to use
    non-owning buffers to avoid copying it. For starting up an otherwise
    empty main isolate, this saves around 1.3 MiB of unique set size memory
    (9.9 MiB -> 8.6 MiB) and 1.1ms elapsed time (22.9 ms -> 21.8 ms).
    
    Copying the code cache is unnecessary since:
    
    1. for the builtin snapshot, the code cache data has static lifetime.
    2. for non-builtin snapshots, we create copies of the code cache data in
       `SnapshotDeserializer::ReadVector`. These copies are owned by the
       `Environment` (through `IsolateData` -> `SnapshotData`), so they
       won't be deallocated.
    3. a worker thread can copy a parent's isolate's code cache, but in that
       case we still know that the parent isolate will outlive the worker
       isolate.
    
    (Admittedly point (2) feels a little fragile from a lifetime
    perspective, and I would be happy to restrict this optimization to the
    builtin snapshot.)
    
    ```console
    $ perf stat -r 100 -e ... ./node -e 0
    
     Performance counter stats for './node -e 0' (100 runs):
    
                 21.78 msec task-clock
                  2760      page-faults
             113161604      instructions
              18437648      branches
                423230      branch-misses
                853093      cache-references
                 41474      cache-misses
    
             0.0225473 +- 0.0000504 seconds time elapsed  ( +-  0.22% )
    
    $ perf stat -r 100 -e ... ./node-main -e 0
    
     Performance counter stats for './node-main -e 0' (100 runs):
    
                 22.91 msec task-clock
                  3102      page-faults
             114890673      instructions
              18751329      branches
                428909      branch-misses
                895721      cache-references
                 45202      cache-misses
    
             0.0233760 +- 0.0000741 seconds time elapsed  ( +-  0.32% )
    ```
    kvakil committed Apr 10, 2023
    Configuration menu
    Copy the full SHA
    52ce477 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7c6b5af View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    158062d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a286b91 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    eb99a86 View commit details
    Browse the repository at this point in the history