generated from rust-vmm/crate-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
misc: Reduce allocations and streamline copies
Add AmlSink::vec specialization for Vec so we can memcpy Convert calls like: `for byte in bytes { sink.byte(byte); }` into `sink.vec(bytes)` Remove all calls to Vec::insert by reordering appends or doing a single memmove and slice copy Evaluation done by timing the tests and tracking allocations with valgrind's dhat, both for heap tracking and memcopy tracking. after/before for total blocks allocated is 6588/8029 = 82% after/before fastest run time is 4.6/5.9 = 78% ``` set -e for x in main allocation_reduction; do git checkout $x echo "=== $x ===" cargo test --release --tests --no-run &>/dev/null exe=$(find target/release/deps -executable -name 'acpi_tables*') sha256sum ${exe} taskset -c 0 hyperfine --shell=none "${exe} --test-threads 1" valgrind --tool=dhat --mode=heap --dhat-out-file=/dev/null ${exe} \ --test-threads 1 > /dev/null valgrind --tool=dhat --mode=copy --dhat-out-file=/dev/null ${exe} \ --test-threads 1 > /dev/null done ``` And the output (with manual removal of extraneous output) ``` === main === Benchmark 1: target/release/deps/acpi_tables-44d55ae4eaed1824 --test-threads 1 Time (mean ± σ): 6.2 ms ± 0.1 ms [User: 2.0 ms, System: 2.9 ms] Range (min … max): 5.9 ms … 6.7 ms 474 runs DHAT --mode=heap Total: 2,452,242 bytes in 8,029 blocks At t-gmax: 75,063 bytes in 654 blocks At t-end: 0 bytes in 0 blocks Reads: 2,953,771 bytes Writes: 2,194,154 bytes DHAT --mode=copy Total: 488,009 bytes in 4,448 blocks === allocation_reduction === Benchmark 1: target/release/deps/acpi_tables-44d55ae4eaed1824 --test-threads 1 Time (mean ± σ): 5.0 ms ± 0.2 ms [User: 1.0 ms, System: 2.8 ms] Range (min … max): 4.6 ms … 5.5 ms 587 runs DHAT --mode=heap Total: 2,410,141 bytes in 6,588 blocks At t-gmax: 75,575 bytes in 654 blocks At t-end: 0 bytes in 0 blocks Reads: 2,920,895 bytes Writes: 2,160,911 bytes DHAT --mode=copy Total: 1,149,621 bytes in 25,894 blocks ``` Signed-off-by: Andrew Consroe <aconz2@gmail.com>
- Loading branch information
Showing
15 changed files
with
75 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.