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

perf(cache): single cache file for remote modules #24983

Merged
merged 8 commits into from
Aug 26, 2024

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Aug 11, 2024

This changes the global cache to store the cache file for remote modules in one file instead of two.

  1. This is better performance as we now do one open file and read instead of two. This will be faster for loading from the deno dir on a network drive or slow storage devices.
  2. This makes the cache more resilient because the two files can't get out of sync (or one of them deleted and not the other one, which was previously the source of bugs).
  3. This has the downside of making the global cache more complicated, but I think it's worth it. (Edit: not that complicated anymore) Proposed format of the file is outlined in perf: single cache file deno_cache_dir#54

On an m2 macbook loading 10k remote modules:

Benchmark 1: ./deno_main run main.ts
  Time (mean ± σ):      1.143 s ±  0.019 s    [User: 1.061 s, System: 0.560 s]
  Range (min … max):    1.101 s …  1.165 s    10 runs
 
Benchmark 2: ./deno_new run main.ts
  Time (mean ± σ):      1.004 s ±  0.011 s    [User: 1.053 s, System: 0.428 s]
  Range (min … max):    0.983 s …  1.022 s    10 runs
 
Summary
  ./deno_new run main.ts ran
    1.14 ± 0.02 times faster than ./deno_main run main.ts

Closes #17707

@dsherret dsherret added this to the 2.0 milestone Aug 11, 2024
.assert_matches_text(
"[WILDCARD]Cache body not found. Trying again without etag.[WILDCARD]",
);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Deleted this test because it's not possible for the two files to get out of sync because there's only one file now.

@bartlomieju bartlomieju modified the milestones: 2.0.0, 2.0.0-rc.1 Aug 26, 2024
@dsherret dsherret marked this pull request as ready for review August 26, 2024 23:12
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, this is indeed much simpler

@dsherret dsherret enabled auto-merge (squash) August 26, 2024 23:36
@dsherret dsherret merged commit c89a20b into denoland:main Aug 26, 2024
17 checks passed
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.

Consider storing remote file cache metadata in same file as text
2 participants