This is an archive of the discontinued LLVM Phabricator instance.

[NFC][MC] `MCInst`: `Operands` small size optimization: store 10, not 8, inline `MCOperand`
ClosedPublic

Authored by lebedev.ri on Dec 12 2022, 2:08 PM.

Details

Summary

This improves the torture test of

./bin/llvm-exegesis -mcpu=znver3 -mode=inverse_throughput --opcode-index=-1 --benchmarks-file=/dev/null --dump-object-to-disk=0 --measurements-print-progress --skip-measurements

from ~2m16s to ~2min07s, and has the following effect on memory:

heaptrack stats:
        allocations:            100828624 -> 77362343 (-23.2%)
        leaked allocations:     1128
        temporary allocations:  24911300  ->  1576308 (-93.7%) !!!

peak heap memory consumption:
        78.2MB after 02.121s    ->   76.4MB after 01.985s (-2.3%)
peak RSS (including heaptrack overhead):
        193.4MB                 ->   192.6MB              (-0.4%)

The reasoning is that having more Operands than the SSO is costly,
because we go to global allocator, but having larger SSO is fine,
even if it's not always needed, because MCInst is hopefully pool-allocated.

I'm not sure who is the code owner of this component.

Diff Detail

Event Timeline

lebedev.ri created this revision.Dec 12 2022, 2:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 12 2022, 2:08 PM
lebedev.ri requested review of this revision.Dec 12 2022, 2:08 PM

More than 8 operands seem high for x86. What am I missing?

More than 8 operands seem high for x86. What am I missing?

Ok I checked. I guess the highest for x86 is 10?

lebedev.ri retitled this revision from [NFC][MC] `MCInst`: `Operands` small size optimization: store 16, not 8, inline `MCOperand` to [NFC][MC] `MCInst`: `Operands` small size optimization: store 10, not 8, inline `MCOperand`.
lebedev.ri edited the summary of this revision. (Show Details)

@craig.topper good point!
10 is still a win, and even decreases total memory footprint.

This revision is now accepted and ready to land.Dec 13 2022, 9:57 AM

LGTM

Thank you for the review!

This revision was landed with ongoing or failed builds.Dec 13 2022, 10:22 AM
This revision was automatically updated to reflect the committed changes.