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

New leak detector #178

Merged
merged 10 commits into from
Jul 18, 2024
Merged

New leak detector #178

merged 10 commits into from
Jul 18, 2024

Conversation

chrisvest
Copy link
Owner

No description provided.

This will make counting leaked objects, and maintaining internal data structures of the leak detector, much faster.
The IdentityHashSet is based on open-addressing 2-choice hashing with 8-element buckets.
Conceptually, this is like bucketed cuckoo-hashing without the cuckoo-ing.
The 8-element buckets, and the addition of an 8-element stash for unresolvable conflicts, allow the table to have high utilisation.
The table array is a power-of-two size, so in practice utilisation will be between 45% to 90+%.
This means it'll take up less memory than the IdentityHashMap-as-a-Set we had before, in part due to not storing values, and in part to using a higher-utilisation hashing algorithm.
Theoretically, the 2-choice hashing scheme have higher access costs, due to computing two hashes and having at least two cache-misses, one from each sub-table, but this doesn't seem to be all that noticeable in the grand scheme of things.
The access performance is dramatically better than the 2-level chaining Bagwell trie we used before, by simply scaling to larger sizes.
The Bagwell trie, as implemented, didn't scale to more than 1000 elements, and relied entirely on chaining for capacities beyond that.
The `toString` was recursive, which is a problem when there are a large number of nodes.
@chrisvest
Copy link
Owner Author

Would be a good idea to inspect the utilisation rate on resizes.

@chrisvest chrisvest added this to the 4.0 milestone Jul 15, 2024
This is useful when Lilliput will start requiring object header inflation for storing identity hash codes.
Identity hash codes are already somewhat expensive to compute on the first call.
Identity hash codes might also not have full 32-bit entropy, which can produce a poor distribution.
This method makes it possible to use alternative pre-computed hash codes, such as a process-wide counter.
…references in the precise leak detector

The added int field hides in alignment padding on most JVM configurations, so the objects won't actually take up more space from this added field.
@chrisvest chrisvest merged commit 1eaaacc into main Jul 18, 2024
5 checks passed
@chrisvest chrisvest deleted the new-leak-detector branch July 18, 2024 03:43
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.

1 participant