Skip to content

ASTCache: use a double weak dictionary #13379

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

Merged
merged 4 commits into from
Apr 11, 2023

Conversation

privat
Copy link
Contributor

@privat privat commented Apr 10, 2023

Based on #13378 for the refactor. Look at the last commit only.

Instead of a WeakIdentityKeyDictionary, that keep forever uninteresting AST.
Use a WeakIdentityKeyWeakValueDictionary! But because this class does not exist, and because I do not want to implement is (and because ephemerons are coming), I just simulate it with a WeakIdentityKeyDictionary of single-cell WeakArrays, and a special loop to remove garbage collected value.

For the rationale, look at #13371 (comment)

@privat
Copy link
Contributor Author

privat commented Apr 10, 2023

Test passed, but the code is ugly.

Some stats (see #13368 for other numbers)

  • after DrTest all tests (1248) of OpalCompiler-Tests: an ASTCache#2 73% (only 2 items instead of 67)
  • after all critiques on Kernel: an ASTCache#127 99% (only 127 items instead of 4317)
  • after one critique on Kernel: an ASTCache#199 0%
  • after all tests (342) of Reflectivity-Tests: an ASTCache#619 97%

So the numbers are lower but are not that reliable: elements are collected on future GC, and it seems that WeakIdentityKeyDictionary have inconsistent size value: {self associations size. self size} >>> #(129 619). so possible the 619 of above is false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants