-
Notifications
You must be signed in to change notification settings - Fork 303
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
Track value category, staleness, and sync state separately for ActorCache::Entries #1033
Conversation
case EntrySyncStatus::NOT_IN_CACHE: { | ||
KJ_FAIL_ASSERT("NOT_IN_CACHE entries should not be in the map or flushing"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking nit: good idea to throw a KJ_UNREACHABLE
after this switch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've never read the actor-cache code before so I'd rather do a second pass in the morning before approving. Happy to see it get cleaned up, especially those switch statements!
src/workerd/io/actor-cache.c++
Outdated
@@ -1414,7 +1409,6 @@ kj::Own<ActorCache::Entry> ActorCache::findInCache( | |||
if (iter != ordered.end() && iter->get()->key == key) { | |||
// Found exact matching entry. | |||
Entry& entry = **iter; | |||
KJ_ASSERT(entry.state != NOT_IN_CACHE, "entry should have been removed from map"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was a eyeing this assert but noticed it wasn't in the final diff so I'll ask here instead. Previously wondered the reasoning for checking NOT_IN_CACHE
directly instead of UNKNOWN
, but why delete this entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could leave it in if you prefer! Basically, this particular assert doesn't have anything to do with this function, we have no reason why we cannot return the entry since we pulled it from the map just now. I'd also be willing to add KJ_IASSERTS
to all the places we set syncStatus
to make sure the previous state is correct.
658d4bb
to
1f55c38
Compare
doh, sorry, for some reason I thought this had already landed. I updated on the comment format which caused a merge conflict. |
No worries, thanks for updating the comment style in general! |
1f55c38
to
8582914
Compare
This also fixes an inconsequential bug wherein we set dummy values to CLEAN instead of NOT_IN_CACHE.
Tracking these unknown values makes our logic around staleness and eviction simpler. It also prevents non-intersecting list calls (which add unknown entries for their end key) from filling up the cache with unevictable entries. Since both unknown (END_GAP) and known (CLEAN) entries can now be stale, entry staleness becomes its own boolean.
This commit introduces separate enum for if a value is present, absent, or unknown that is constant for the lifetime of an `Entry`. This makes our logic in several places clearer and provides the ground work for coalescing reads (since we'll need an entry in cache for them).
Since we have now moved staleness and value category to their own bytes, we can shrink down our sync status to its own byte and make it clearer that it indicates membership in various maps and lists.
8582914
to
18d864c
Compare
Revert "Merge pull request #1033 from cloudflare/bcaimano/actor-cache-no-state
This PR is paving the way for us to start coalescing reads/gets in the actor cache. The general plan looks like this:
To that end, we're splitting the entry state into its three component parts:
Sadly, this is a bit longer than I was hoping it would be. That said, the number of actual behavior changes should be relatively low. The biggest changes are around what is considered evictable (unknown entries now are) and how strict we are about tracking when something is in the cache.