jameysharp requested cfallin for a review on PR #4951.
jameysharp opened PR #4951 from shrink-abiarg
to main
:
We weren't using the "union" cargo feature for the smallvec crate, which reduces the size of a SmallVec by one machine word. This feature requires Rust 1.49 but we already require much newer versions.
I also reduced ABIArgSlot::Stack::offset from i64 to i32, so it fits in the same space as ABIArgSlot::Reg::reg. This eliminates all padding from ABIArgSlot, saving 8 bytes there. Without that change, ABIArg wouldn't shrink even though it contains a SmallVec.
When using Wasmtime to compile pulldown-cmark from Sightglass, this saves a decent amount of memory allocations and writes. According to
valgrind --tool=dhat
:
- 6.3MiB (3.78%) less memory allocated over the program's lifetime
- 0.5MiB (4.16%) less memory allocated at maximum heap size
- 5.6MiB (1.94%) fewer bytes written to
- 0.5% fewer instructions executed
Reducing the size of SmallVecs also shrinks other types by varying amounts. Here are some types that shrink by quite a bit but aren't allocated often:
- 264 bytes: cranelift_codegen::machinst::buffer::MachBuffer
- 112 bytes: cranelift_codegen::machinst::abi::SigData
- 64 bytes: wasmtime_cranelift::compiler::CompilerContext
- 56 bytes: cranelift_codegen::context::Context
Here are some types which don't shrink by a lot, but are allocated very often:
- 16 bytes: cranelift_codegen::isa::x64::inst::CallInfo
- 16 bytes: cranelift_codegen::machinst::abi::Caller
- 8 bytes: cranelift_codegen::machinst::buffer::MachBranch
- 8 bytes: cranelift_frontend::ssa::SSABlockData
- 8 bytes: regalloc2::ion::data_structures::LiveBundle
- 8 bytes: regalloc2::ion::data_structures::LiveRange
- 8 bytes: regalloc2::ion::data_structures::SpillSet
- 8 bytes: regalloc2::ion::data_structures::SpillSlotList
- 8 bytes: regalloc2::ion::data_structures::VRegData
- 8 bytes: regalloc2::ion::process::AllocRegResult
- 8 bytes: regalloc2::moves::MoveVecWithScratch
- 8 bytes: regalloc2::moves::ParallelMoves
<!--
Please ensure that the following steps are all taken care of before submitting
the PR.
[ ] This has been discussed in issue #..., or if not, please tell us why
here.[ ] A short description of what this does, why it is needed; if the
description becomes long, the matter should probably be discussed in an issue
first.[ ] This PR contains test cases, if meaningful.
- [ ] A reviewer from the core maintainer team has been assigned for this PR.
If you don't know who could review this, please indicate so. The list of
suggested reviewers on the right can help you.Please ensure all communication adheres to the code of conduct.
-->
jameysharp requested fitzgen for a review on PR #4951.
cfallin submitted PR review.
jameysharp updated PR #4951 from shrink-abiarg
to main
.
jameysharp merged PR #4951.
Last updated: Dec 23 2024 at 12:05 UTC