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

Fix bug in semispace cache that allowed gen1 to contain values in evi… #1162

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

matthughes
Copy link
Contributor

…cted.

else SemispaceCache(Map(k -> v), gen0, max, evicted ++ gen1.values - v)// no room in gen0, slide it down
def insert(k: K, v: V): SemispaceCache[K, V] =
if (max == 0) SemispaceCache(gen0, gen1, max, evicted + v) // immediately evict
else if (gen0.size < max) SemispaceCache(gen0 + (k -> v), gen1 - k, max, evicted - v) // room in gen0, remove from gen1, done!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If gen0 or gen1 contains (k, v0) such that v0 != v, we should add v0 to evicted list. Likewise below.

new SemispaceCache[K, V](gen0, gen1, max, evicted) {}
private def apply[K, V](gen0: Map[K, V], gen1: Map[K, V], max: Int, evicted: EvictionSet[V]): SemispaceCache[K, V] = {
val r = new SemispaceCache[K, V](gen0, gen1, max, evicted) {}
val gen0Intersection: Set[V] = (gen0.values.toSet intersect evicted.toList.toSet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop these assertions now? I worry a bit about all these set creations/intersections on each constructor?

@mpilquist mpilquist merged commit b314c69 into typelevel:main Jan 15, 2025
10 checks passed
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