Repository navigation
fix(runtime): keep span async slice begin/end ordered; release 0.1.0-ALPHA03 - #172
Merged
Merged
Conversation
The span transition and the matching beginAsyncSection/endAsyncSection call were two steps, so a concurrent Started could overtake a Finished and emit begin, begin, end on the same cookie. Perfetto then showed only the first part of the span. Run both inside one atomic per-key operation and add a multi-threaded regression test.
Bump RUNTIME_VERSION to 0.1.0-ALPHA03 and update the install snippets in the runtime READMEs and the changelog.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a concurrency bug in the
span:<name>async slice thatAndroidTraceSinkemits (#169), and bumps the runtime family to0.1.0-ALPHA03.Bug: the span transition (map update) and the matching
beginAsyncSection/endAsyncSectioncall were two separate steps. Under concurrency aStartedcould overtake aFinishedand emitbegin, begin, endon the same cookie, so Perfetto showed only the first part of the span.Evidence (Android 15 emulator, PoC
android-coroutine-storm, unbounded scenario, 2000 dispatches over ~1.3 s):0.1.0-ALPHA02: the span appears as 3 slices covering ~110 ms.Fix: run the map transition and the trace call inside one atomic per-key operation (
compute/computeIfPresent), so begin/end strictly alternate. Trace-API failures are swallowed inside it so state stays consistent.Known limitation (unchanged, documented)
A span is still drawn as several consecutive slices when no segment of it is running for a moment (gaps under 1 ms in the trace above).
Test plan
New multi-threaded regression test
concurrentSegmentsOfOneSpanAlternateBeginAndEndStrictly(8 threads x 5000 start/finish pairs). It failed before the fix (224 out-of-order transitions in one run) and passes now, 5 forced reruns. No public API change.Relates to #168