KEMBAR78
Reduce size of HTML Flame Graph · Issue #864 · async-profiler/async-profiler · GitHub
Skip to content

Reduce size of HTML Flame Graph #864

@apangin

Description

@apangin

Background

async-profiler dumps a Flame Graph as a JavaScript having one function call per frame:

f(165,557,1,1,'dotty/tools/dotc/core/Types$TypeMap.mapArgs')
f(166,557,1,1,'dotty/tools/dotc/core/Types$TypeMap.mapArgs')
f(167,557,1,1,'dotty/tools/dotc/core/Types$TypeMap.mapArgs')
f(168,557,1,1,'dotty/tools/dotc/core/Types$TypeMap.mapArgs')
f(56,558,7,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genWhileDo')
f(57,558,7,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genLoad')
f(58,558,7,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genBlock')
f(59,558,7,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genLoad')
f(60,558,7,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genLoadIf')
f(61,559,6,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genLoad')
f(62,559,6,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genLoadIf')
f(63,559,6,1,'dotty/tools/backend/jvm/BCodeBodyBuilder$PlainBodyBuilder.genLoad')

Many frames have the same title which is repeated each time.
We can reduce the script size by deduplicating frame titles.

Proposal

Move strings representing frame titles to a separate array (constant pool), and refer this array by indices.

As an example, string deduplication reduces the flame graph size of the dotty benchmark by 2.5x.
Further compression of the string pool and frame descriptors leads to the total of 5.5x size reduction.

Old Flame Graph + String dedup + Compression
4182 KB 1644 KB 759 KB

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions