-
Notifications
You must be signed in to change notification settings - Fork 48
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
Unbuffered event stream. #144
Comments
There were also some ideas on Zulip around using "non-temporal" (i.e. cache-bypassing) stores to the |
For reference, there was a (half-hearted) attempt to do that in https://github.com/rust-lang/measureme/pull/16/files. It was abandoned due to lack of time and because existing |
Thanks for writing that up, @eddyb! This protocol looks quite promising to me. I like how it basically keeps the file format intact and is actually not that hard to understand (surprisingly so for something involving locks and atomic operations 😄) The main obstacle I see is the handling |
For growing, I came up with this hack: The "slow path" for events can grab the same lock that non-event pages use, and then we can have a common codepath for all writes, inside the lock. Even though events would've already Even if this is practically unlikely, if there are enough threads that Once everything is either waiting for a lock (or bumping
|
I spoke too soon 😉 |
It occurs to me that I don't know why we would want multiple threads to write to the same page - do we need the exact original interleaving? IIRC we split the event streams into threads anyway. It would also be more efficient for every event page to contain the thread ID once and not waste space in the events in the page. Event pagesIf each thread has its own "active event page", only running out of space in that needs any synchronization, and it can be a single Once we've reserved the offset of a page we could If the (EDIT: randomly stumbled about NixOS/nixpkgs#101490 (comment) which suggests not all filesystems support Non-event pagesFor non-event pages we could have them managed globally under a lock, while sharing the common Overall this is a much simpler design, assuming we never want to avoid doing thread deinterleaving.
I think I've been confused before by the lack of a separate cc @wesleywiser |
To avoid hitting a
Mutex
for every event being recorded, and assuming that all the other streams have (much) lower frequency, we could keep the current format, while recording it differently:mmap
'd file, we don't want to actually hit a syscall hereAtomicUsize
)fetch_add
on the sameAtomicUsize
position (that writing events uses), effectively "closing" the "currently open" events page (new events would effectively end up in a newer page)Sadly bypassing
File
entirely will probably be most of the work here, I don't fully understand whymeasureme
never properlymmap
'd a file-on-disk (the pre-pagingmmap
s were "anonymous", i.e. no different than ungrowableVec<u8>
s).I'm also not sure how we'd handle not being able to grow the
mmap
'd region (not without re-adding locking to writing events), we need to be on a 64-bit host to even grab gratuitous amounts of virtual memory, without hampering the rest of the process, don't we?Maybe for 32-bit hosts we can keep paging events and writing to a
File
?cc @michaelwoerister @wesleywiser
The text was updated successfully, but these errors were encountered: