lpereira opened PR #8107 from lpereira:better-metrics
to bytecodealliance:main
:
This is just a first pass at trying to gather some insights that might lead to memory savings later. For instance, by compiling SpiderMonkey with this patch, we get these metrics out:
Key(machinst.buffer.data): 0.0: 4 0.5: 412.0315874877959 0.9: 1636.1480687972453 1.0: 110084
Key(machinst.buffer.relocs): 0.0: 0 0.5: 1.9999056357269998 0.9: 9.999149133010329 1.0: 600
Key(machinst.buffer.traps): 0.0: 0 0.5: 11.999920242205052 0.9: 57.00277828432678 1.0: 3833
Key(machinst.buffer.call_sites): 0.0: 0 0.5: 1.9999056357269998 0.9: 9.999149133010329 1.0: 600Which suggest that the fields in MachBuffer struct could be reduced:
- Half of the functions are under 412 bytes; most are under 1.6kB.
- Half of the functions have 2 relocs; most have at most 10.
- Half of the functions have 12 traps; most have at most 57. The default allocation of 16 is probably OK for this field.
- Half of the functions have 2 call sites; most have at most 10.
Of course, there's only one MachBuffer per thread compiling code, so the savings here are marginal, but this approach could be used in other parts of the code to find more useful things.
The output formatting at this point is pretty crude as this is merely a proof-of-concept, but something better can be made later if necessary.
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
Last updated: Dec 23 2024 at 12:05 UTC