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

refactor(perf): replace sync struct HeaderView with HeaderIndexView #3970

Merged
merged 1 commit into from
May 12, 2023

Conversation

quake
Copy link
Member

@quake quake commented May 6, 2023

What problem does this PR solve?

resolve #3940

What is changed and how it works?

replace the struct HeaderView of sync mod with a more memory compact struct HeaderIndexView, and avoid holding headers messages in memory (remove bytes slice clone).

Compare with v0.109.0, this PR reduced the peak memory usage from 3.8G to 2.8G during IBD sync on my local PC. @jiangxianliang007 also did test on an aws c5.xlarge instance (4C8G), it reduced from 3.2G to 2.3G, sync performance has also improved, from 0 to 9 million, dropping from 19 hours and 25 minutes to 17 hours and 30 minutes.

please not that this PR didn't replace the HeaderMap storage sled with other solution, there is another PR in testing

Check List

Tests

  • Unit test
  • Integration test

Release note

Title Only: Include only the PR title in the release note.

@quake quake requested a review from a team as a code owner May 6, 2023 03:22
@quake quake requested review from doitian, zhangsoledad and eval-exec and removed request for a team May 6, 2023 03:22
@@ -101,7 +101,7 @@ bootnode_mode = false
support_protocols = ["Ping", "Discovery", "Identify", "Feeler", "DisconnectMessage", "Sync", "Relay", "Time", "Alert", "LightClient", "Filter"]

# [network.sync.header_map]
# memory_limit = "600MB"
# memory_limit = "256MB"
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed the default memory limit to smaller one, it can keep about the same amount of header data in memory as before.

Some(status.contains(BlockStatus::BLOCK_STORED)),
)?
.into_inner();
.get_header_index_view(&parent_hash, false)?;
Copy link
Member Author

Choose a reason for hiding this comment

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

we have checked the status if contains BLOCK_STORED in line 148 and returned early, no need to check it again here.

sync/src/types/header_map/mod.rs Outdated Show resolved Hide resolved
@eval-exec eval-exec added the t:enhancement Type: Feature, refactoring. label May 6, 2023
@quake quake force-pushed the quake/header-index-view branch from e29af19 to 0c8e91e Compare May 12, 2023 01:04
@quake quake force-pushed the quake/header-index-view branch from 0c8e91e to 62e3454 Compare May 12, 2023 01:05
@quake quake added this pull request to the merge queue May 12, 2023
Merged via the queue into nervosnetwork:develop with commit a98679d May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:enhancement Type: Feature, refactoring.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Memory tuning on header synchronization
5 participants