deno_cache icon indicating copy to clipboard operation
deno_cache copied to clipboard

perf: single cache file

Open dsherret opened this issue 1 year ago • 0 comments

This is for Deno 2. See https://github.com/denoland/deno/issues/17707 for details.

Format:

<content>\n// denoCacheMetadata=<metadata><EOF>

File format considerations:

  1. We can reuse the original vector we read the file from by storing the content first and then truncating the vector to the content.
  2. The file has a comment on the last line. This makes it still work if loaded as a TS/JS file. Obviously it will not work if this is something like Wasm and someone loads that, but when deno reads this file it removes the comment.
  3. The metadata is json. This makes it easier to add properties in the future.
  4. It's probably best for perf to read this file in one shot to reduce fs calls (especially on network drives), so reading the whole file and extracting out the metadata is ok.
  5. We still want users to easily read the code in this file if they inspect it (so it doesn't use binary)

dsherret avatar Aug 10 '24 14:08 dsherret