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

Share liberally in the analyzer #96

Merged
merged 1 commit into from
Sep 21, 2023
Merged

Conversation

iamrecursion
Copy link
Contributor

Summary

Prior to this commit, state forks would deep clone potentially quite large value trees. This would create many duplicated values that were then incorporated into further trees.

Now, rather than having unique ownership of each tree node using Box<T>, the analyzer instead shares these as much as possible through use of Arc<T>. This has resulted in significant improvements in memory usage, and similarly significant improvements to execution time by eliminating the need to perform many allocations.

In addition to this, we are also more careful about how we retain values. When transforming RSV to TCSV, we would previously retain the vector of all runtime values until all of those values had been transformed. Now we drop runtime values eagerly wherever possible. This has resulted in a reduction to peak residency.

As part of this work, some investigation was done as to the quadratic traversal of value trees in the InferenceState during transformation. While a variety of single-pass approaches were tried, the current approach managed to outperform all of them. A comment has been added to indicate this, and to be careful when changing it.

Closes #69
Closes #79
Closes #85

Details

Just the usual things.

Checklist

  • Code is formatted by Rustfmt.
  • Documentation has been updated if necessary.

@iamrecursion iamrecursion added the enhancement New feature or request label Sep 20, 2023
@iamrecursion iamrecursion self-assigned this Sep 20, 2023
Base automatically changed from wip/ara/proxy-slots to main September 21, 2023 17:36
Prior to this commit, state forks would deep clone potentially quite
large value trees. This would create many duplicated values that were
then incorporated into further trees.

Now, rather than having unique ownership of each tree node using
`Box<T>`, the analyzer instead shares these as much as possible through
use of `Arc<T>`. This has resulted in significant improvements in memory
usage, and similarly significant improvements to execution time by
eliminating the need to perform many allocations.

In addition to this, we are also more careful about how we retain
values. When transforming `RSV` to `TCSV`, we would previously retain
the vector of all runtime values until all of those values had been
transformed. Now we drop runtime values eagerly wherever possible. This
has resulted in a reduction to peak residency.

As part of this work, some investigation was done as to the quadratic
traversal of value trees in the `InferenceState` during transformation.
While a variety of single-pass approaches were tried, the current
approach managed to outperform all of them. A comment has been added to
indicate this, and to be careful when changing it.
@iamrecursion iamrecursion merged commit d321365 into main Sep 21, 2023
5 checks passed
@iamrecursion iamrecursion deleted the wip/ara/liberal-sharing branch September 21, 2023 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants