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

WIP: Share negative cache entries across Symbolicators #1523

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions crates/symbolicator-service/src/caching/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,25 @@ impl<T: CacheItemRequest> Cacher<T> {
// TODO: Not handling negative caches probably has a huge perf impact. Need to
// figure out negative caches. Maybe put them in redis with a TTL?
if !shared_cache_hit {
if let Ok(byteview) = &entry {
if let Some(shared_cache) = shared_cache {
shared_cache.store(name, &cache_path, byteview.clone(), CacheStoreReason::New);
if let Some(shared_cache) = shared_cache {
match &entry {
Ok(byteview) => {
shared_cache.store(
name,
&cache_path,
byteview.clone(),
CacheStoreReason::New,
);
}
Err(CacheError::NotFound) => {
shared_cache.store(
name,
&cache_path,
ByteView::from_slice(b""), // Store an empty file to indicate source not found.
CacheStoreReason::New,
);
}
Err(_) => {}
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions crates/symbolicator-service/src/caching/shared_cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,42 @@ mod tests {
assert_eq!(buf, b"");
}

#[tokio::test]
async fn test_filesystem_empty_store() {
symbolicator_test::setup();
let dir = symbolicator_test::tempdir();

let key = "global/some_item";

let cfg = SharedCacheConfig {
max_concurrent_uploads: 10,
max_upload_queue_size: 10,
backend: SharedCacheBackendConfig::Filesystem(FilesystemSharedCacheConfig {
path: dir.path().to_path_buf(),
}),
};
let svc = SharedCacheService::new(Some(cfg), tokio::runtime::Handle::current());
let svc = wait_init(&svc).await;

let recv = svc.store(
CacheName::Objects,
key,
ByteView::from_slice(b""),
CacheStoreReason::New,
);
// Wait for storing to complete.
recv.await.unwrap();

let temp_file = NamedTempFile::new_in(&dir).unwrap();
let file = File::from_std(temp_file.reopen().unwrap());

let ret = svc.fetch(CacheName::Objects, key, file).await;
assert!(ret); // We find something.

let buf = std::fs::read(temp_file).unwrap();
assert_eq!(buf, b""); // But the thing we find is an empty file.
}

#[tokio::test]
async fn test_filesystem_store() {
symbolicator_test::setup();
Expand Down
Loading