[XS] Change in dart/sdk[main]: [vm] Mark _OperatorEqualsAndHashCode._hashCode for inlining

0 views
Skip to first unread message

Slava Egorov (Gerrit)

unread,
10:11 AM (8 hours ago) 10:11 AM
to Jens Johansen, dart-...@luci-project-accounts.iam.gserviceaccount.com, dart2wasm-t...@google.com, rev...@dartlang.org
Attention needed from Jens Johansen

Slava Egorov voted

Code-Review+1
Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Jens Johansen
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I07a8fb097e46ab48c26bcf7896b12c7312ededc3
Gerrit-Change-Number: 509000
Gerrit-PatchSet: 2
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-Attention: Jens Johansen <je...@google.com>
Gerrit-Comment-Date: Wed, 03 Jun 2026 14:11:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

dart-scoped@luci-project-accounts.iam.gserviceaccount.com (Gerrit)

unread,
10:11 AM (8 hours ago) 10:11 AM
to Jens Johansen, Slava Egorov, dart2wasm-t...@google.com, rev...@dartlang.org

dart-...@luci-project-accounts.iam.gserviceaccount.com submitted the change

Change information

Commit message:
[vm] Mark _OperatorEqualsAndHashCode._hashCode for inlining

In a valgrind "profile" of a run of an aot-compiled version of
`pkg/analyzer/tool/stable_analysis.dart` I noticed that
`_OperatorEqualsAndHashCode._hashCode` was called 40,288,281 times,
costing - by itself, i.e. without the actual cost of getting the
underlying hashCode - 723,483,274 instructions - about 1.79% of the
total cost.

Interestingly `_OperatorEqualsAndHashCode._equals` wasn't there, so that
one must be inlined (whereas the `_hashCode` isn't). Stepping via GDB
confirms both things.

Via the inlining tracing in the vm via

```
out/ReleaseX64/dart-sdk/bin/dart \
compile aot-snapshot --verbose \
--extra-gen-snapshot-options="--print_inlining_tree" \
pkg/analyzer/tool/stable_analysis.dart
```

I found

```
Inlining into: 'dart:_compact_hash___Map&_LinkedHashBase&MapMixin&_HashBase&_OperatorEqualsAndHashCode&_LinkedHashMapMixin@3099033_[]='
growth: 0.000000 (9 -> 0)
NO 14 __Map&_LinkedHashBase&MapMixin&_HashBase&_OperatorEqualsAndHashCode@3099033._hashCode@3099033 - Heuristic fail (no small leaf)
NO 16 __Map&_LinkedHashBase&MapMixin&_HashBase&_OperatorEqualsAndHashCode&_LinkedHashMapMixin@3099033._set@3099033 - Not inlinable
```

In `runtime/vm/compiler/backend/inliner.cc` I saw that I could avoid
this "no small leaf" thing by marking it for inlining.

Running stable_analysis through `perf stat` without and with this CL I
get:

```
Without CL:
39,552,232,456 instructions:u
39,552,392,619 instructions:u
39,554,905,123 instructions:u
```

```
With this CL:
39,024,836,004 instructions:u
39,022,158,372 instructions:u
39,022,782,198 instructions:u
```

So this "only" saves something like 527 million instructions (~1.3%),
i.e. less than the ~723 million instructions hoped for, but I'll take
it.
Change-Id: I07a8fb097e46ab48c26bcf7896b12c7312ededc3
Reviewed-by: Slava Egorov <veg...@google.com>
Commit-Queue: Slava Egorov <veg...@google.com>
Files:
  • M sdk/lib/_internal/vm_shared/lib/compact_hash.dart
Change size: XS
Delta: 1 file changed, 1 insertion(+), 0 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Slava Egorov
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I07a8fb097e46ab48c26bcf7896b12c7312ededc3
Gerrit-Change-Number: 509000
Gerrit-PatchSet: 3
Gerrit-Owner: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Jens Johansen <je...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages