-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Significantly refactored trace aggregator
Previously we were leaking `ThreadTracer` objects in the `TraceAggregator` as creating new threads means `ThreadTracer` gets pushed into `TraceAggregator` but it is never removed. This causes a memory leak and also makes the `TraceAggregator` slower. This refactors the entire code to make this work. Some of the highlights are: - Removed the feature of dynamically adding in trace `Sink`s. `Sink` can now only be specified when the trace session is started. Since we don't really have any use case of dynamically hooking in sinks, this feature is a lot of complexity for no reason. - This also removed the sticky packet feature within the `TraceAggregator` which saved additional complexity. - Remove the feature of the `TraceAggregator` mirroring data to multiple `Sink`s. This is also unnecessary. Could create a `MultiSink` feature if necessary to emulate this. So now, when you start a trace session, you must give a single sink for the data to be pushed to. - `TraceAggregator` is now a permanent object (as a `shared_ptr`) on the `App` instead of being dynamically created and deleted when the trace session is started and stopped. This skips the need of having App cache the list of `ThreadTracer`s and pass it to the `TraceAggregator` during its construction when the trace session starts. - Instead, the `TraceAggregator` internally has a `SessionData` object (`session_`). This object is recreated and deleted when the trace session starts and stops. - Since the `TraceAggregator` is permanent now, the `Thread` directly register the `ThreadTracer` with the `TraceAggregator` during its start up procedure. This replaces registering through the `App`. The `Thread` are also now holding a `weak_ptr` to the `TraceAggregator`. - When a thread shuts down, the `ThreadTracer` is marked as "done". The `TraceAggregator` will check for this "done" status if no more events are available from the queue. If it is done, the `ThreadTracer` will be removed from the `TraceAggregator`. - `TraceAggregator` no longer supports `RequestStop` and `Join`. This is replaced with a single `Stop` call which will wait for the `TraceAggregator` to fully stop and reset the state of the TraceAggregator (and any registered `ThreadTracer`'s string interner). - Right now, there is a potential data race during the `TraceAggregator.Stop`, as we access `session_` without a lock. This is most likely OK as we don't expect `TraceAggregator.Stop` to be called from multiple threads or rapidly recreated for now. **Should probably fix it in the future.** - String interner states are now reset when a trace session stops. This means if another trace session is started, the strings it remembers are reset. The id starting positions are also reset. - Since we no longer have sticky packets, we also no longer emit a trace event packet that contains interned data from a previous trace session.
- Loading branch information
Showing
17 changed files
with
264 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.