Commit 95d3767a authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[code cache] De-duplicate large double-keyed cache entries

- Changes very large code entry writing to create an indirection. The
  first entry is double-keyed just like other size entries. However, it
  contains response time, size, and a hashed checksum of the data. The
  checksum is used as a second key for another entry that contains a
  no header and the actual code.
- Changes very large code entry fetches to do a double-keyed read as
  before. If there is a checksum in the header, that is used as a
  second key to read the actual code.
- Every origin that loads a given resource for the first time will
  get a cache miss. To get a cache hit, the origin must first generate
  code and write it to the cache. The code is checksummed using SHA-256
  to make it very unlikely for a malicious origin to store its code to
  the same key as another origin. Origins that generate identical code
  share the same code entry.

Design Document:
https://docs.google.com/document/d/1SCH15oCFJW55jsTJZ0T7XAQIZVryI_IJOIENyL_q4n4/edit

Bug:chromium:936107

Change-Id: If99d2dada102382d51f97286fb3e5d9d2faf3aa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1846102
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: default avatarMythri Alle <mythria@chromium.org>
Reviewed-by: default avatarChris Palmer <palmer@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarMaksim Orlovich <morlovich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707389}
parent 804eeab2
......@@ -119,7 +119,14 @@ class CONTENT_EXPORT GeneratedCodeCache {
enum BackendState { kInitializing, kInitialized, kFailed };
// The operation requested.
enum Operation { kFetch, kWrite, kDelete, kGetBackend };
enum Operation {
kFetch,
kFetchWithSHAKey,
kWrite,
kWriteWithSHAKey,
kDelete,
kGetBackend
};
// Data streams corresponding to each entry.
enum { kSmallDataStream = 0, kLargeDataStream = 1 };
......@@ -130,6 +137,9 @@ class CONTENT_EXPORT GeneratedCodeCache {
scoped_refptr<base::RefCountedData<ScopedBackendPtr>> backend_ptr,
int rv);
// Adds operation to the appropriate queue.
void EnqueueOperation(std::unique_ptr<PendingOperation> op);
// Issues ops that were received while the backend was being initialized.
void IssuePendingOperations();
void IssueOperation(PendingOperation* op);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment