Repository navigation
Conversation
`--reset-memory` (next commit) needs to count the threads of the runtime, which `#[tokio::main]` does not allow. The four binaries that run an iteration loop now call `util::build_runtime`. It has the settings of `#[tokio::main]`, so this commit does not change behavior. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… iteration mimalloc keeps freed memory for reuse, so the time of an iteration depends on what ran before it in the same process. `--reset-memory` collects the mimalloc heap of every runtime thread before each iteration, outside the timed part. It is off by default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@alamb @HippoBaro (because we talked about similar in arrow-rs) i'm curious what you think of this change. from my measurements it seems that there's a lot of "lottery" effect that causes benchmark noise because each iteration of each query depends on the state of allocated memory in the run before it. i'm open to other ideas on how to address this problem if this is not a good solution, and i'm happy to walk through what i tried that didn't work. |
alamb
left a comment
There was a problem hiding this comment.
Love the idea -- I had some questions on specific details
| run(&gates, Some(handle)) | ||
| } | ||
|
|
||
| /// Returns all free memory of all threads to the OS. Must run on the thread |
There was a problem hiding this comment.
the idea of returning all memory to the OS is a good one in my opinion
It is entirely unclear to me how this works -- is the idea that it tracks all threads and ensures that they have all exited? It would really help to document the design somewhere
Also if we are going to do this, why not always enable it? It seems like more reproducability would be a good thing in general so what is the usecase for not always clearing?
A review asked how the reset works. The module doc now explains why a collection must run on each thread, how the barrier holds each thread, and why the threads stay alive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
||
| #[cfg(all(feature = "mimalloc", feature = "mimalloc_extended"))] | ||
| fn collect() { | ||
| // SAFETY: `mi_collect` has no preconditions. |
There was a problem hiding this comment.
maybe this sould help to point out that mi_collect basically returns state to the OS?
| ) -> bool { | ||
| let deadline = Instant::now() + timeout; | ||
| let expected = workers + blocking + 1; | ||
| let gates: Arc<[Gate; 3]> = |
There was a problem hiding this comment.
This is some crazy magic to me -- why are there 3 gates? What is this implementing? It seems like this is just trying to run a future on each thread?
A review asked why on_every_thread uses three gates, and what mi_collect does. Doc and comments only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Which issue does this PR close?
Rationale for this change
mimalloc keeps freed memory for reuse.
dfbenchruns every query in one process, so the time of an iteration depends on what ran before it. A benchmark of a PR must not depend on that.In an A/A experiment on a
c4a-standard-16VM, with 6 ClickBench queries, running another query first made an iteration slower:This experiment used an earlier prototype of the reset. A larger run on three VMs (43 queries, forward and reversed order, injected regressions) is in progress. This PR stays a draft until its results are in.
What changes are included in this PR?
Two commits, best reviewed in order:
--reset-memory. It returns free memory to the OS before each iteration, outside the timed part. It is off by default.mi_collectempties only the heap of the calling thread. So the reset blocks one task on each runtime thread at a barrier, and then collects twice:mimalloc_extended, or usessnmallocNot in this PR:
interleave.pydoes not pass the flag yet, andmimalloc_extendedis not a default feature.What is the testing strategy for this PR?
interleave.pyon a small dataset, and in a build withoutmimalloc_extendedto check the error../dev/rust_lint.shpasses, exceptcheck_docs_html.sh, which needs tools that I do not have locally. This PR does not changedocs/.Are there any user-facing changes?
No change for DataFusion users. The benchmark binaries have a new
--reset-memoryflag.New public items in the unpublished
datafusion-benchmarkscrate:util::build_runtime,CommonOpt::reset_memory, andSampler::with_reset_memory.🤖 Generated with Claude Code