Skip to content
This repository has been archived by the owner on Jul 26, 2024. It is now read-only.

Avoid the cache "dog-piling" effect #46

Closed
ncloudioj opened this issue Apr 12, 2021 · 0 comments
Closed

Avoid the cache "dog-piling" effect #46

ncloudioj opened this issue Apr 12, 2021 · 0 comments

Comments

@ncloudioj
Copy link
Collaborator

ncloudioj commented Apr 12, 2021

Noticed this when I was exploring the codebase the other day. In a highly concurrent environment, the "dog-piling effect" might cause unnecessary cache writes and wasteful recomputations for the same missing keys.

Upon a cache miss, Contile currently relies on the request handler to fetch the missing tiles from content partners and store the result in the local cache. Given Firefox's user base, it's possible to have multiple requests asking for tiles for the same missing cache key at the same time. In that case, each one of them would try to make an external tile request and then write the result to the cache, which could be redundant and unnecessary if the cached value is identical.

While this is not a logical problem, the underlying overheads, such as locking and issuing external requests, might have a negative impact. Also, this effect could be worse when we add cache TTL and emergency purging functionalities in the future.

I've made this example to demonstrate this issue and provided a solution to it. Will prepare a patch later.

┆Issue is synchronized with this Jira Task
┆Epic: Contile Shared tiles cache

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants