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

Remove Hash cache in Node<T> #872

Merged
merged 3 commits into from
Jun 25, 2024
Merged

Remove Hash cache in Node<T> #872

merged 3 commits into from
Jun 25, 2024

Conversation

SimonSapin
Copy link
Contributor

Hashing is much less important to apollo-compiler as it was when we were using Salsa. Many of the structs stored in Node<_> don’t even implement Hash since they contain IndexMap which doesn’t.

We lose: potential CPU time if repeatedly hashing nodes. ast::Definition implements PartialEq and Hash by traversing the whole subtree, which can be expensive. We gain: 8 fewer bytes in the heap allocation of every Node, and slightly less code complexity.

Hashing is much less important to apollo-compiler as it was
when we were using Salsa. Many of the structs stored in `Node<_>`
don’t even implement `Hash` since they contain `IndexMap` which doesn’t.

We lose: potential CPU time if repeatedly hashing nodes.
`ast::Definition` implements `PartialEq` and `Hash` by traversing
the whole subtree, which can be expensive.
We gain: 8 fewer bytes in the heap allocation of every `Node`,
and slightly less code complexity.
@SimonSapin
Copy link
Contributor Author

Added a changelog entry, and the Borrow impl that would have been semantically incorrect with the cache.

@SimonSapin SimonSapin enabled auto-merge (squash) June 25, 2024 14:23
@SimonSapin SimonSapin merged commit d4bcc9b into main Jun 25, 2024
11 of 12 checks passed
@SimonSapin SimonSapin deleted the unhash branch June 25, 2024 14:25
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.

None yet

2 participants