Shopify / seafoam

A tool for working with compiler graphs dumped by the GraalVM compiler
MIT License
126 stars 22 forks source link

Add option to not simplify, and run passes before describe #66

Closed chrisseaton closed 1 year ago

chrisseaton commented 1 year ago

Fixes #65

Before:

% bundle exec bin/seafoam examples/fib-ruby.bgv.gz:2 describe --no-simplify
138 nodes, branches, calls
ConstantNode: 15
LoadIndexedNode: 8
PiNode: 5
FixedGuardNode: 4
BoxNode$AllocatingBoxNode: 3
BoxNode$TrustedBoxedValue: 3
UnboxNode: 3
AllocatedObjectNode: 2
BeginNode: 2
CommitAllocationNode: 2
DeoptimizeNode: 2
EndNode: 2
ExceptionObjectNode: 2
IntegerSubExactNode: 2
IntegerSubExactOverflowNode: 2
InvokeWithExceptionNode: 2
KillingBeginNode: 2
MethodCallTargetNode: 2
VirtualArrayNode: 2
IfNode: 1
IntegerAddExactNode: 1
IntegerAddExactOverflowNode: 1
IntegerLessThanNode: 1
MergeNode: 1
ObjectEqualsNode: 1
ParameterNode: 1
PiArrayNode: 1
ReturnNode: 1
StartNode: 1
ValuePhiNode: 1

After:

% bundle exec bin/seafoam examples/fib-ruby.bgv.gz:2 describe
148 nodes, branches, calls
ConstantNode: 7
FixedGuardNode: 4
BoxNode$AllocatingBoxNode: 3
BoxNode$TrustedBoxedValue: 3
UnboxNode: 3
*TruffleArgument: 2
*TruffleNew: 2
DeoptimizeNode: 2
ExceptionObjectNode: 2
IntegerSubExactNode: 2
IntegerSubExactOverflowNode: 2
InvokeWithExceptionNode: 2
KillingBeginNode: 2
MethodCallTargetNode: 2
IfNode: 1
IntegerAddExactNode: 1
IntegerAddExactOverflowNode: 1
IntegerLessThanNode: 1
MergeNode: 1
ObjectEqualsNode: 1
ReturnNode: 1
StartNode: 1
ValuePhiNode: 1

Note that synthetic nodes have a * in front of their name.

CC @eregon

chrisseaton commented 1 year ago

Did you want to keep KillingBegin in when you hid Begin?

eregon commented 1 year ago

It seems the node count (148 nodes, branches, calls) doesn't consider hidden nodes from that output.

eregon commented 1 year ago

Did you want to keep KillingBegin in when you hid Begin?

That no longer exists since oracle/graal@9149851f8e83d3a79974e95004d1733ec6305549, so I don't think it's worth handling it.

chrisseaton commented 1 year ago

doesn't consider hidden nodes

Wasn't that what you wanted?

eregon commented 1 year ago

Bad phrasing, the node count is higher after this PR than before, that's unexpected, i.e., it should be < 138 nodes (and I think the sum of the histogram is < 138).

chrisseaton commented 1 year ago

Ah the overall count - I'll fix that.

chrisseaton commented 1 year ago
% bundle exec bin/seafoam examples/fib-ruby.bgv.gz:2 describe
47 nodes, branches, calls
ConstantNode: 7
FixedGuardNode: 4
BoxNode$AllocatingBoxNode: 3
BoxNode$TrustedBoxedValue: 3
UnboxNode: 3
*TruffleArgument: 2
*TruffleNew: 2
DeoptimizeNode: 2
ExceptionObjectNode: 2
IntegerSubExactNode: 2
IntegerSubExactOverflowNode: 2
InvokeWithExceptionNode: 2
KillingBeginNode: 2
MethodCallTargetNode: 2
IfNode: 1
IntegerAddExactNode: 1
IntegerAddExactOverflowNode: 1
IntegerLessThanNode: 1
MergeNode: 1
ObjectEqualsNode: 1
ReturnNode: 1
StartNode: 1
ValuePhiNode: 1
eregon commented 1 year ago

Looks good, and that's almost a third of the nodes, making it clear the passes are quite worth it to simplify the graph.