Skip to content

Commit

Permalink
[Turbopack] use thread local trace collecting (#73615)
Browse files Browse the repository at this point in the history
### What?

Collect trace events in a thread local buffer first and then send a batch of events to the writer thread.

But there are some challenges to that:

Events might be out of order in the trace file. Usually that should be fine since they have a timestamp, but

* span ids might be reused faster than all events are send to the file. So we assign our own globally unique ids instead.
* the trace server need to be able to process events out of order. So we queue up events when they are received for spans that are not created yet.

And the thread local buffer might also have a problem when the thread is idle or hanging. This would cause events to never be written to the file.
To fix that the writer thread will steal the outstanding events from the thread local buffers when it is idle for a second. This ensures that all events are eventually written, even in case of hanging threads.
  • Loading branch information
sokra authored Dec 10, 2024
1 parent e0eb165 commit dfa14fb
Show file tree
Hide file tree
Showing 6 changed files with 573 additions and 231 deletions.
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dfa14fb

Please sign in to comment.