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

Simplify ShapeId caching #1411

Merged
merged 1 commit into from
Sep 17, 2022
Merged

Simplify ShapeId caching #1411

merged 1 commit into from
Sep 17, 2022

Conversation

mtdowling
Copy link
Member

The previous implementation could cause a recursive update error when a shape ID is purged from the cache because it attempted to remove an element from the ConcurrentHashMap inside of a computeIfAbsent call. This updated approach is simpler and instead separates prelude shape IDs into a ConcurrentHashMap that just stops caching after 500 entries are in the cache (which does more than cover the shapes currently in the prelude), and uses a synchronized LinkedHashMap to function as an LRU cache for all other shape IDs. The performance of this approach vs what we had previously is essentially the same.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling requested a review from a team as a code owner September 16, 2022 23:27
The previous implementation could cause a recursive update error when
a shape ID is purged from the cache because it attempted to remove an
element from the ConcurrentHashMap inside of a computeIfAbsent call.
This updated approach is simpler and instead separates prelude shape
IDs into a ConcurrentHashMap that just stops caching after 500 entries
are in the cache (which does more than cover the shapes currently in
the prelude), and uses a synchronized LinkedHashMap to function as an
LRU cache for all other shape IDs. The performance of this approach
vs what we had previously is essentially the same.
@mtdowling mtdowling merged commit 83a5626 into main Sep 17, 2022
@srchase srchase deleted the fix-shapeid-cache branch October 13, 2022 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants