Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cp 1.10] Memory improvements/limits for DelayedFields (#12580, #12583, #12581) #12594

Merged
merged 4 commits into from
Mar 21, 2024

Conversation

igor-aptos
Copy link
Contributor

Combined three memory related changes into this cherry-pick : #12580, #12583, #12581

This reduces memory footprint of amortized usage of delayed field with a single version from 3000 bytes to 600 bytes per delayed field.
Basically BTreeMap stores things in vectors of 5, and size of the value is large. This invalidates BTreeMap's cache optimization of storing them all together.
Copy link

trunk-io bot commented Mar 19, 2024

⏱️ 8h 46m total CI duration on this PR
Job Cumulative Duration Recent Runs
windows-build 1h 46m 🟩🟩🟩🟩
rust-unit-tests 1h 45m 🟥🟩🟩🟩
rust-move-unit-coverage 1h 21m 🟥🟩🟩
rust-move-tests 52m 🟥🟩🟩
rust-smoke-tests 30m 🟩
rust-lints 28m 🟥🟩🟩🟩
execution-performance / single-node-performance 20m 🟩
check 16m 🟩🟩🟩🟩
rust-images / rust-all 16m 🟩
run-tests-main-branch 15m 🟥🟥🟥🟥
forge-e2e-test / forge 14m 🟩
forge-compat-test / forge 13m 🟩
general-lints 9m 🟩🟩🟩🟩
check-dynamic-deps 8m 🟩🟩🟩🟩
cli-e2e-tests / run-cli-tests 7m 🟩
semgrep/ci 2m 🟩🟩🟩🟩
node-api-compatibility-tests / node-api-compatibility-tests 51s 🟩
file_change_determinator 44s 🟩🟩🟩🟩
file_change_determinator 38s 🟩🟩🟩🟩
file_change_determinator 11s 🟩
permission-check 10s 🟩🟩🟩🟩
execution-performance / file_change_determinator 10s 🟩
permission-check 10s 🟩🟩🟩🟩
permission-check 10s 🟩🟩🟩🟩
permission-check 10s 🟩🟩🟩🟩
permission-check 3s 🟩
determine-docker-build-metadata 3s 🟩

🚨 3 jobs on the last run were significantly faster/slower than expected

Job Duration vs 7d avg Delta
rust-move-unit-coverage 35m 18m +94%
rust-unit-tests 36m 27m +33%
windows-build 25m 21m +21%

settingsfeedbackdocs ⋅ learn more about trunk.io

@igor-aptos igor-aptos requested review from sherry-x and removed request for davidiw, wrwg, movekevin and sasha8 March 19, 2024 20:23
igor-aptos and others added 2 commits March 19, 2024 14:38
temporarily, until gas charges for aggregator loading are implemented, limit number of aggregators per resource
@igor-aptos igor-aptos force-pushed the igor/blockstm_mem_cherry_pick branch from 63ac82d to 907a74f Compare March 19, 2024 21:38
@igor-aptos igor-aptos requested a review from vusirikala March 19, 2024 22:05
@@ -246,6 +246,17 @@ impl DelayedFieldValue {
},
})
}

/// Approximate memory consumption of current DelayedFieldValue
pub fn get_approximate_memory_size(&self) -> usize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "approximate"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I am not sure about the exact footprint of the vector, and actual size doesn't matter, as there is a lot of uncertainty in the maps that store these as well.

@@ -211,6 +213,22 @@ pub static BLOCK_COMMITTED_TXNS: Lazy<HistogramVec> = Lazy::new(|| {
.unwrap()
});

pub static BLOCK_VIEW_DISTINCT_KEYS: Lazy<HistogramVec> = Lazy::new(|| {
register_avg_counter_vec(
"aptos_execution_block_view_distinct_keys",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What "keys" does this refer to? Comments would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keys in the view, every map (resource/resource_group/modules/delayed_fields has different key), and each is broken down separately

I am going to leave documentation improvements to follow-up PR on main, as this is a cherry-pick to release branch, not the original PR


pub static BLOCK_VIEW_BASE_VALUES_MEMORY_USAGE: Lazy<HistogramVec> = Lazy::new(|| {
register_avg_counter_vec(
"aptos_execution_block_view_base_values_memory_usage",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "base values" mean here? Comments would be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base value / storage version, basically not the versions from writes, but from storage

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 96.07843% with 8 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (aptos-release-v1.10@7dc6f5c). Click here to learn what that means.

Files Patch % Lines
crates/aptos-metrics-core/src/avg_counter.rs 54.5% 5 Missing ⚠️
aptos-move/e2e-move-tests/src/aggregator_v2.rs 62.5% 3 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##             aptos-release-v1.10   #12594   +/-   ##
======================================================
  Coverage                       ?    71.7%           
======================================================
  Files                          ?      811           
  Lines                          ?   185848           
  Branches                       ?        0           
======================================================
  Hits                           ?   133364           
  Misses                         ?    52484           
  Partials                       ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@igor-aptos igor-aptos enabled auto-merge (squash) March 21, 2024 00:02

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

✅ Forge suite compat success on aptos-node-v1.9.5 ==> 4cecc57fd739cfe0c1dd325b2b04668e21b790dc

Compatibility test results for aptos-node-v1.9.5 ==> 4cecc57fd739cfe0c1dd325b2b04668e21b790dc (PR)
1. Check liveness of validators at old version: aptos-node-v1.9.5
compatibility::simple-validator-upgrade::liveness-check : committed: 5485 txn/s, latency: 5041 ms, (p50: 4800 ms, p90: 8400 ms, p99: 13200 ms), latency samples: 230400
2. Upgrading first Validator to new version: 4cecc57fd739cfe0c1dd325b2b04668e21b790dc
compatibility::simple-validator-upgrade::single-validator-upgrade : committed: 1155 txn/s, latency: 24057 ms, (p50: 26500 ms, p90: 32100 ms, p99: 35300 ms), latency samples: 56640
3. Upgrading rest of first batch to new version: 4cecc57fd739cfe0c1dd325b2b04668e21b790dc
compatibility::simple-validator-upgrade::half-validator-upgrade : committed: 261 txn/s, submitted: 434 txn/s, expired: 173 txn/s, latency: 39671 ms, (p50: 42700 ms, p90: 58200 ms, p99: 87900 ms), latency samples: 29010
4. upgrading second batch to new version: 4cecc57fd739cfe0c1dd325b2b04668e21b790dc
compatibility::simple-validator-upgrade::rest-validator-upgrade : committed: 2318 txn/s, latency: 12956 ms, (p50: 13900 ms, p90: 15300 ms, p99: 16400 ms), latency samples: 102000
5. check swarm health
Compatibility test for aptos-node-v1.9.5 ==> 4cecc57fd739cfe0c1dd325b2b04668e21b790dc passed
Test Ok

Copy link
Contributor

✅ Forge suite realistic_env_max_load success on 4cecc57fd739cfe0c1dd325b2b04668e21b790dc

two traffics test: inner traffic : committed: 7064 txn/s, latency: 5534 ms, (p50: 5300 ms, p90: 6900 ms, p99: 13800 ms), latency samples: 3066040
two traffics test : committed: 100 txn/s, latency: 2112 ms, (p50: 1900 ms, p90: 2300 ms, p99: 6600 ms), latency samples: 1760
Latency breakdown for phase 0: ["QsBatchToPos: max: 0.280, avg: 0.213", "QsPosToProposal: max: 0.259, avg: 0.207", "ConsensusProposalToOrdered: max: 0.565, avg: 0.540", "ConsensusOrderedToCommit: max: 0.400, avg: 0.387", "ConsensusProposalToCommit: max: 0.952, avg: 0.927"]
Max round gap was 2 [limit 4] at version 1350420. Max no progress secs was 9.11326 [limit 15] at version 1350420.
Test Ok

@igor-aptos igor-aptos merged commit f789b74 into aptos-release-v1.10 Mar 21, 2024
86 checks passed
@igor-aptos igor-aptos deleted the igor/blockstm_mem_cherry_pick branch March 21, 2024 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants