Add Flamegraph HTML to Uploaded Profile Data#1022
Open
artursarlo wants to merge 1 commit intodynamic_profilingfrom
Open
Add Flamegraph HTML to Uploaded Profile Data#1022artursarlo wants to merge 1 commit intodynamic_profilingfrom
artursarlo wants to merge 1 commit intodynamic_profilingfrom
Conversation
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.
Add Flamegraph HTML to Uploaded Profile Data
Summary
Includes the flamegraph HTML as a field (
flamegraph_html) inside the profile metadata that is uploaded with each snapshot. This allows consumers of the uploaded data to render the flamegraph directly from the profile payload without regenerating it client-side.Additionally, the flamegraph template has been updated to be fully responsive.
Changes
gprofiler/merge.pyflamegraph_html: Optional[str]as a parameter to_make_profile_metadata,concatenate_profiles, andmerge_profiles.# {...}) under the key"flamegraph_html".Nonein the public-facing functions to preserve backward compatibility.gprofiler/main.py_generate_flamegraph_html()method: Splits flamegraph generation logic out of_generate_output_files()into a standalone method that accepts stripped collapsed stack data and start/end times, returning the rendered HTML string orNoneon failure (with a warning log)._generate_output_files(): Now delegates to_generate_flamegraph_html()instead of inlining the generation logic._snapshot(): Before producing the final merged result, a temporary merge is performed using the sameNoopProfiler/perf branching logic to obtain the full collapsed stacks. The flamegraph HTML is generated from this temporary result and passed to the finalconcatenate_profiles/merge_profilescalls via the newflamegraph_htmlparameter.gprofiler/resources/flamegraph/flamegraph_template.htmlmax(1400, window.innerWidth * 0.98)instead of a fixed 960px.resizeevent listener to reflow the chart on window resize.max-width/widthset to99%, reduced horizontal padding, addedmargin: 0tobody.Motivation
The
intel_dynamic_profilingad-hoc flow uploads snapshots to a backend. Previously, the flamegraph was only written to disk when--flamegraphwas enabled; the uploaded metadata had no HTML representation of the call stacks. This change embeds the pre-rendered HTML in the upload payload so the backend can surface the flamegraph without any additional processing.Testing
--flamegraphis enabled, the uploaded profile's metadata JSON will contain aflamegraph_htmlkey with the full HTML string.--flamegraphis disabled or flamegraph generation fails,flamegraph_htmlisnullin the metadata..coland.htmlfiles written to--output-dir) is unchanged.