Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #358 +/- ##
==========================================
- Coverage 91.22% 89.84% -1.38%
==========================================
Files 21 21
Lines 4272 4481 +209
==========================================
+ Hits 3897 4026 +129
- Misses 375 455 +80 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Owner
Author
|
This took me forever to get around to, but here's finally a first draft of a more reasonable crate API for inferno. Would love to get input from the various people interested in #30, #164, and #270, like @koute, @Licenser, @Kixiron, @itamarst, and @stepancheg. I also figure that once we land this, we're probably ready to mark inferno as 1.0 👀 |
Inferno's library API was purely text-based: collapsers produce `"stack;frames count\n"` lines, and flamegraph parses them back. Downstream tools with structured stack data had to round-trip through text, causing escaping issues, wasted work, and loss of type safety (issues #30, #164, #270). This commit adds a typed API alongside the existing text path. The core type is `Sample<S>`, generic over the stack iterator, which replaces the text line `"main;foo;bar 42"`. Three new entry points accept iterators of `Sample`: `from_sorted_stacks` (requires pre-sorted input), `from_stacks` (sorts internally), and `flame_chart_from_stacks` (preserves time ordering). On the collapse side, `Collapse::collapse_to_stacks` returns a `FoldedStacks` wrapper whose `samples()` method yields typed `Sample` values for direct rendering without text serialization. `CollapsePrivate` implementors get an efficient override that skips text entirely; other `Collapse` implementors get a default that round-trips through text that they can override if able. `Options` is now `Clone` and has no lifetime parameter. The mutable `palette_map` reference moves to a separate parameter on all public functions, and text-processing fields (`no_sort`, `reverse_stack_order`, `flame_chart`, `base`) move to a new `PreProcessingOptions` struct that is only needed by the text-based entry points. This is a breaking API change, hence the version bump to `1.0.0-rc.1`.
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.
Inferno's library API was purely text-based: collapsers produce
"stack;frames count\n"lines, and flamegraph parses them back. Downstream tools with structured stack data had to round-trip through text, causing escaping issues, wasted work, and loss of type safety (issues #30, #164, #270).This commit adds a typed API alongside the existing text path. The core type is
Sample<S>, generic over the stack iterator, which replaces the text line"main;foo;bar 42". Three new entry points accept iterators ofSample:from_sorted_stacks(requires pre-sorted input),from_stacks(sorts internally), andflame_chart_from_stacks(preserves time ordering). On the collapse side,Collapse::collapse_to_stacksreturns aFoldedStackswrapper whosesamples()method yields typedSamplevalues for direct rendering without text serialization.CollapsePrivateimplementors get an efficient override that skips text entirely; otherCollapseimplementors get a default that round-trips through text that they can override if able.Optionsis nowCloneand has no lifetime parameter. The mutablepalette_mapreference moves to a separate parameter on all public functions, and text-processing fields (no_sort,reverse_stack_order,flame_chart,base) move to a newPreProcessingOptionsstruct that is only needed by the text-based entry points.This is a breaking API change, hence the version bump to
1.0.0-rc.1.