Skip to content

Commit d2b4f75

Browse files
committed
Prevent excessive specialization for the flamegraphitem function
Before this change, this would specialize in two undesireable ways (at least on Julia v1.7): almost every tree node has a different type (depending on its depth) and for the output function, closures wrap closures in a long tower, which also gives different types for each.
1 parent 6802467 commit d2b4f75

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

haml/flamegraph.hamljl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
%rect(x=0.0, y=0, width=1200.0, height=height, fill="url(#background)")/
1515
%text(text_anchor="", x=10.0, y=height, font_size=12, font_family="Verdana",
1616
fill="rgb(0,0,0)", dominant_baseline="ideographic", id="details")= " "
17-
- @include("flamegraphitem.hamljl", report=$report, node=$report.flamegraph,
17+
- @include("flamegraphitem.hamljl", report=$report, node=Ref{Any}($report.flamegraph),
1818
x=Ref(0.0), y=height-20-16, scale = 1200.0 / $report.tracecount)
1919
-# vim: set filetype=haml:

haml/flamegraphitem.hamljl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- pt = TracePoint($node.data.sf)
2-
- span = $node.data.span
1+
- pt = TracePoint($node[].data.sf)
2+
- span = $node[].data.span
33
- cnt = length(span)
44
- width = $scale * cnt
55
- label = pt.containing_function.name
@@ -17,8 +17,8 @@
1717
%rect(x=$x[], y=$y, width=width, height=15.0, fill=fillcolor, rx=2, ry=2)/
1818
%text(text_anchor="", x=$x[] + 3, y=$y + 10.5, font_size=12, font_family="Verdana", fill="rgb(0,0,0)")= show_label ? label : " "
1919
- curx = Ref($x[])
20-
- for child in $node
21-
- @include("flamegraphitem.hamljl", report=$report, node=child,
20+
- for child in $node[]
21+
- @output render_flamegraphitem(report=$report, node=Ref{Any}(child),
2222
x=curx, y=$y - 16, scale=$scale)
2323
- $x[] += width
2424
-# vim: set filetype=haml:

src/HTML.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module HTML
33
import Base64: base64encode
44

55
import Dates: format, RFC1123Format
6-
import HAML: includehaml, @include, @surround, @cdatafile
6+
import HAML: includehaml, @include, @surround, @cdatafile, @output
77

88
import ..Reports: Report, FunctionPoint, TracePoint
99

@@ -15,6 +15,7 @@ includehaml(@__MODULE__,
1515
:render_files => templatefile("files.hamljl"),
1616
:render_methods => templatefile("methods.hamljl"),
1717
:render_flamegraph => templatefile("flamegraph.hamljl"),
18+
:render_flamegraphitem => templatefile("flamegraphitem.hamljl"),
1819
)
1920

2021
outputfilename(::Nothing) = ""

0 commit comments

Comments
 (0)