Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Optimize aligned memory used by the runtime #17324

Merged
merged 1 commit into from
May 19, 2021

Conversation

jackcmay
Copy link
Contributor

Problem

The AlignedMemory implementation added a new and superfluous memset in cases where the data was later written incrementally (most pronounced in program parameter serialization). This is causing performance degradation.

Summary of Changes

  • Rework the aligned memory implementation to remove the memset, includes other optimizations utilized in other areas of the rbpf (and thus runtime)
  • Added serialization benches

Fixes #

@jeffwashington
Copy link
Contributor

raw results on master. serialize 78s with this change vs 108s without this change

jack:
ledger processing timing ExecuteTimings check_us 1623487 load_us 30607593 execute_us 257297503 store_us 70930243 details ExecuteDetailsTimings serialize_us 78524207 create_vm_us 12694585 execute_us 39198653 deserialize_us 41360025 changed_account_count 212316 total_account_count 5313048 total_data_size 341233366608 data_size_changed 4066129474
ledger processed in 3 minutes and 24 seconds. root slot is 76820740 1 fork at 76820780 with 37 frozen banks

master
ledger processing timing ExecuteTimings check_us 1546815 load_us 28623897 execute_us 287027755 store_us 65587266 details ExecuteDetailsTimings serialize_us 108053806 create_vm_us 12027731 execute_us 39847740 deserialize_us 40752505 changed_account_count 212316 total_account_count 5313048 total_data_size 341233366608 data_size_changed 4066129474
ledger processed in 3 minutes and 36 seconds. root slot is 76820740 1 fork at 76820780 with 37 frozen banks

@jeffwashington
Copy link
Contributor

1.6 looks good at first glance. I will work this into the graph. I ran jack's change twice to make sure it really was that fast:

jack 1.6:
ledger processing timing ExecuteTimings check_us 1813310 load_us 163932199 execute_us 283908612 store_us 127102701 details ExecuteDetailsTimings serialize_us  41239102 create_vm_us 12642299 execute_us 40188027 deserialize_us 35009657 changed_account_count 418476 total_account_count 5834166 total_data_size 372337745651 data_size_changed 16219497930
ledger processed in 5 minutes and 1 second. 55019 MB allocated. root slot is 76820740 1 fork at 76820780 with 37 frozen banks
ledger processing timing ExecuteTimings check_us 1785740 load_us 163823277 execute_us 283017909 store_us 127010841 details ExecuteDetailsTimings serialize_us 41133678 create_vm_us 12580657 execute_us 39946844 deserialize_us 35045918 changed_account_count 418476 total_account_count 5834166 total_data_size 372337745651 data_size_changed 16219497930
ledger processed in 5 minutes and 1 second. 55067 MB allocated. root slot is 76820740 1 fork at 76820780 with 37 frozen banks

1.6:
ledger processing timing ExecuteTimings check_us 1829167 load_us 167772692 execute_us 406036035 store_us 127593625 details ExecuteDetailsTimings serialize_us 153063242 create_vm_us 14000456 execute_us 47955506 deserialize_us 28170237 changed_account_count 418476 total_account_count 5834166 total_data_size 372337745651 data_size_changed 16219497930
ledger processed in 6 minutes and 5 seconds. 57645 MB allocated. root slot is 76820740 1 fork at 76820780 with 37 frozen banks

@jeffwashington
Copy link
Contributor

jeffwashington commented May 19, 2021

confirmed that #17324, cherry-picked to v1.6, restores performance of replay. metrics spreadsheet for 1.6 updated

@mvines mvines added the v1.6 label May 19, 2021
@jackcmay jackcmay force-pushed the optimize-aligned-memory branch from c194697 to 4aa73b2 Compare May 19, 2021 16:29
@jeffwashington
Copy link
Contributor

updated metrics spreadsheet for master. looks good

@jackcmay jackcmay merged commit 477898f into solana-labs:master May 19, 2021
@jackcmay jackcmay deleted the optimize-aligned-memory branch May 19, 2021 20:44
mergify bot pushed a commit that referenced this pull request May 19, 2021
(cherry picked from commit 477898f)

# Conflicts:
#	cli/Cargo.toml
#	programs/bpf/Cargo.toml
#	programs/bpf_loader/Cargo.toml
#	programs/bpf_loader/src/syscalls.rs
mergify bot added a commit that referenced this pull request May 19, 2021
* Optimize aligned memory used by the runtime (#17324)

(cherry picked from commit 477898f)

# Conflicts:
#	cli/Cargo.toml
#	programs/bpf/Cargo.toml
#	programs/bpf_loader/Cargo.toml
#	programs/bpf_loader/src/syscalls.rs

* resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
@brooksprumo brooksprumo mentioned this pull request Aug 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants