-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Miri: GC the dead_alloc_map too #118073
Miri: GC the dead_alloc_map too #118073
Conversation
☔ The latest upstream changes (presumably #118134) made this pull request unmergeable. Please resolve the merge conflicts. |
3e740e5
to
6b21acc
Compare
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri The Miri subtree was changed cc @rust-lang/miri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does make me rather nervous since we're generally relying on the dead_alloc_map having information about all past allocations. But I guess if an AllocId cannot be found anywhere in the machine state then we cannot possibly care about it in the dead_alloc_map, either...
ef49af4
to
f5dae8e
Compare
Thanks. :) |
Do you know which data structures? |
Stack and Tree if I recall. It's not a particularly challenging profiling to do again. |
Well yeah that is not very specific. But when we're just creating and removing allocations, I don't see why any stacks or trees would keep growing. |
☀️ Test successful - checks-actions |
Finished benchmarking commit (38eecca): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 676.494s -> 677.592s (0.16%) |
Yeah, I think I'll need to cook up some special profiling to understand what's going on. All the existing tools just tell you "this call stack allocated" which is not enlightening.
Ah! I'm observing such behavior in property tests or other long running test suites, which surely do more than just create and remove allocations. I suspect there is some global data structure that is accessed or aliased constantly over the tests, and it accumulates dead state that the GC doesn't know how to remove. Or perhaps all the state is live. In either case, I'll need to do some custom tooling to understand it. But I don't think the remaining memory growth is a big concern. With the rate it's at now, I think I'm running out of patience long before I run out of memory. So I might just post an issue about what's going on here then not work on it unless I can find a test suite where the memory growth is concerning. |
dead_alloc_map is the last piece of state in the interpreter I can find that leaks. With this PR, all of the long-term memory growth I can find in Miri with programs that do things like run a big
loop {
or run property tests is attributable to some data structure properties in borrow tracking, and is extremely slow.My only gripe with the commit in this PR is that I don't have a new test for it. I'd like to have a regression test for this, but it would have to be statistical I think because the peak memory of a process that Linux reports is not exactly the same run-to-run. Which means it would have to not be very sensitive to slow leaks (some guesswork suggests for acceptable CI time we would be checking for like 10% memory growth over a minute or two, which is still pretty fast IMO).
Unless someone has a better idea for how to detect a regression, I think on balance I'm fine with manually keeping an eye on the memory use situation.
r? RalfJung