-
Notifications
You must be signed in to change notification settings - Fork 174
refactor(l1): improve snap sync logging with table format #5977
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
365416d
refactor(l1): improve snap sync logging with table format
pablodeymo 08dac92
docs: add snap sync logging improvement to CHANGELOG
pablodeymo e0870e2
Update crates/networking/p2p/network.rs
pablodeymo 1b54381
Merge branch 'main' into improve-snap-sync-logging-table-format
pablodeymo 625ba8c
refactor(l1): simplify snap sync logging table to single-column format
pablodeymo 68beede
chore(l1): increase snap sync log refresh rate from 10s to 30s
pablodeymo 35c6fc3
chore(l1): change engine API logs from INFO to DEBUG
pablodeymo c619990
Trying to update pivot and Succesfully updated pivot log messages mov…
pablodeymo 1c2a3d7
"Retrieving sync head block number from peers", "Sync head block numb…
pablodeymo ec5f7d9
improve log levels in snap_sync function
pablodeymo 2c1770e
improve logs in request_block_headers, request_account_range and requ…
pablodeymo dbd9682
Headers and bytecode Inserted rows removed
pablodeymo c1ce933
adding downloads per secong for each kind of element
pablodeymo 1faad0d
elements per second
pablodeymo 26a5a7a
fix to start and finish download headers
pablodeymo c05442e
removed throttle from table
pablodeymo 11c5335
Healing as rows
pablodeymo 20aad18
numbers in table
pablodeymo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ use std::{ | |
| io, | ||
| net::SocketAddr, | ||
| sync::{Arc, atomic::Ordering}, | ||
| time::{Duration, SystemTime}, | ||
| time::Duration, | ||
| }; | ||
| use tokio::net::{TcpListener, TcpSocket, UdpSocket}; | ||
| use tokio_util::task::TaskTracker; | ||
|
|
@@ -200,177 +200,92 @@ pub async fn periodically_show_peer_stats_during_syncing( | |
| // We just clamp it to the max to avoid showing the user confusing data | ||
| let headers_downloaded = | ||
| u64::min(METRICS.downloaded_headers.get(), headers_to_download); | ||
| let headers_remaining = headers_to_download.saturating_sub(headers_downloaded); | ||
| let headers_download_progress = if headers_to_download == 0 { | ||
| "0%".to_string() | ||
| let headers_percentage = if headers_to_download == 0 { | ||
| 0.0 | ||
| } else { | ||
| (headers_downloaded as f64 / headers_to_download as f64) * 100.0 | ||
| }; | ||
| let elapsed_secs = start.elapsed().as_secs(); | ||
| let headers_per_second = if elapsed_secs == 0 { | ||
| 0 | ||
| } else { | ||
| format!( | ||
| "{:.2}%", | ||
| (headers_downloaded as f64 / headers_to_download as f64) * 100.0 | ||
| ) | ||
| headers_downloaded / elapsed_secs | ||
| }; | ||
|
|
||
| // Account leaves metrics | ||
| let account_leaves_downloaded = | ||
| METRICS.downloaded_account_tries.load(Ordering::Relaxed); | ||
| let account_leaves_inserted = METRICS.account_tries_inserted.load(Ordering::Relaxed); | ||
| let account_leaves_inserted_percentage = if account_leaves_downloaded != 0 { | ||
| (account_leaves_inserted as f64 / account_leaves_downloaded as f64) * 100.0 | ||
| } else { | ||
| 0.0 | ||
| }; | ||
| let account_leaves_pending = | ||
| account_leaves_downloaded.saturating_sub(account_leaves_inserted); | ||
| let account_leaves_time = format_duration({ | ||
| let end_time = METRICS | ||
| .account_tries_download_end_time | ||
| .lock() | ||
| .await | ||
| .unwrap_or(SystemTime::now()); | ||
|
|
||
| METRICS | ||
| .account_tries_download_start_time | ||
| .lock() | ||
| .await | ||
| .map(|start_time| { | ||
| end_time | ||
| .duration_since(start_time) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }); | ||
| let account_leaves_inserted_time = format_duration({ | ||
| let end_time = METRICS | ||
| .account_tries_insert_end_time | ||
| .lock() | ||
| .await | ||
| .unwrap_or(SystemTime::now()); | ||
|
|
||
| METRICS | ||
| .account_tries_insert_start_time | ||
| .lock() | ||
| .await | ||
| .map(|start_time| { | ||
| end_time | ||
| .duration_since(start_time) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }); | ||
| let accounts_per_second = | ||
| if let Some(start_time) = *METRICS.account_tries_download_start_time.lock().await { | ||
| let elapsed_secs = start_time.elapsed().map(|d| d.as_secs()).unwrap_or(0); | ||
| if elapsed_secs == 0 { | ||
| 0 | ||
| } else { | ||
| account_leaves_downloaded / elapsed_secs | ||
| } | ||
| } else { | ||
| 0 | ||
| }; | ||
|
|
||
| // Storage leaves metrics | ||
| let storage_leaves_downloaded = METRICS.storage_leaves_downloaded.get(); | ||
| let storage_leaves_inserted = METRICS.storage_leaves_inserted.get(); | ||
| let storage_leaves_inserted_percentage = if storage_leaves_downloaded != 0 { | ||
| storage_leaves_inserted as f64 / storage_leaves_downloaded as f64 * 100.0 | ||
| } else { | ||
| 0.0 | ||
| }; | ||
| // We round up because of the accounts whose slots get downloaded and then not used | ||
| let storage_leaves_inserted_percentage = | ||
| (storage_leaves_inserted_percentage * 10.0).round() / 10.0; | ||
| let storage_leaves_time = format_duration({ | ||
| let end_time = METRICS | ||
| .storage_tries_download_end_time | ||
| .lock() | ||
| .await | ||
| .unwrap_or(SystemTime::now()); | ||
|
|
||
| METRICS | ||
| .storage_tries_download_start_time | ||
| .lock() | ||
| .await | ||
| .map(|start_time| { | ||
| end_time | ||
| .duration_since(start_time) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }); | ||
| let storage_leaves_inserted_time = format_duration({ | ||
| let end_time = METRICS | ||
| .storage_tries_insert_end_time | ||
| .lock() | ||
| .await | ||
| .unwrap_or(SystemTime::now()); | ||
|
|
||
| METRICS | ||
| .storage_tries_insert_start_time | ||
| .lock() | ||
| .await | ||
| .map(|start_time| { | ||
| end_time | ||
| .duration_since(start_time) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }); | ||
|
|
||
| // Healing stuff | ||
| let heal_time = format_duration({ | ||
| let end_time = METRICS | ||
| .heal_end_time | ||
| .lock() | ||
| .await | ||
| .unwrap_or(SystemTime::now()); | ||
| let storage_per_second = | ||
| if let Some(start_time) = *METRICS.storage_tries_download_start_time.lock().await { | ||
| let elapsed_secs = start_time.elapsed().map(|d| d.as_secs()).unwrap_or(0); | ||
| if elapsed_secs == 0 { | ||
| 0 | ||
| } else { | ||
| storage_leaves_downloaded / elapsed_secs | ||
| } | ||
| } else { | ||
| 0 | ||
| }; | ||
|
|
||
| METRICS | ||
| .heal_start_time | ||
| .lock() | ||
| .await | ||
| .map(|start_time| { | ||
| end_time | ||
| .duration_since(start_time) | ||
| .expect("Failed to get storage tries download time") | ||
| }) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }); | ||
| // Healing metrics | ||
| let healed_accounts = METRICS | ||
| .global_state_trie_leafs_healed | ||
| .load(Ordering::Relaxed); | ||
| let healed_storages = METRICS | ||
| .global_storage_tries_leafs_healed | ||
| .load(Ordering::Relaxed); | ||
| let heal_current_throttle = | ||
| if METRICS.healing_empty_try_recv.load(Ordering::Relaxed) == 0 { | ||
| "Database" | ||
| } else { | ||
| "Peers" | ||
| }; | ||
|
|
||
| // Bytecode metrics | ||
| let bytecodes_download_time = format_duration({ | ||
| let end_time = METRICS | ||
| .bytecode_download_end_time | ||
| .lock() | ||
| .await | ||
| .unwrap_or(SystemTime::now()); | ||
|
|
||
| METRICS | ||
| .bytecode_download_start_time | ||
| .lock() | ||
| .await | ||
| .map(|start_time| { | ||
| end_time | ||
| .duration_since(start_time) | ||
| .expect("Failed to get storage tries download time") | ||
| }) | ||
| .unwrap_or(Duration::from_secs(0)) | ||
| }); | ||
|
|
||
| let bytecodes_downloaded = METRICS.downloaded_bytecodes.load(Ordering::Relaxed); | ||
| let bytecodes_per_second = | ||
| if let Some(start_time) = *METRICS.bytecode_download_start_time.lock().await { | ||
| let elapsed_secs = start_time.elapsed().map(|d| d.as_secs()).unwrap_or(0); | ||
| if elapsed_secs == 0 { | ||
| 0 | ||
| } else { | ||
| bytecodes_downloaded / elapsed_secs | ||
| } | ||
| } else { | ||
| 0 | ||
| }; | ||
|
|
||
| // Truncate hash to first 6 hex chars | ||
| let head_short = format!("{:x}", current_header_hash); | ||
| let head_short = &head_short[..6.min(head_short.len())]; | ||
|
|
||
| info!( | ||
| r#" | ||
| P2P Snap Sync | elapsed {elapsed} | peers {peer_number} | step {current_step} | head {current_header_hash:x} | ||
| headers : {headers_downloaded}/{headers_to_download} ({headers_download_progress}), remaining {headers_remaining} | ||
| accounts: downloaded {account_leaves_downloaded} @ {account_leaves_time} | inserted {account_leaves_inserted} ({account_leaves_inserted_percentage:.1}%) in {account_leaves_inserted_time} | pending {account_leaves_pending} | ||
| storage : downloaded {storage_leaves_downloaded} @ {storage_leaves_time} | inserted {storage_leaves_inserted} ({storage_leaves_inserted_percentage:.1}%) in {storage_leaves_inserted_time} | ||
| healing : accounts {healed_accounts}, storages {healed_storages}, elapsed {heal_time}, throttle {heal_current_throttle} | ||
| bytecodes: downloaded {bytecodes_downloaded} in {bytecodes_download_time}"# | ||
| ─────────────────────────────────────────────────────────────────────── | ||
| SNAP SYNC │ {elapsed} │ {peer_number} peers │ {current_step} │ {head_short} | ||
| ─────────────────────────────────────────────────────────────────────── | ||
| 1. Headers Downloaded {headers_downloaded:>13} {headers_percentage:>5.1}% {headers_per_second} headers/s | ||
| 2. Accounts Downloaded {account_leaves_downloaded:>13} {accounts_per_second} accounts/s | ||
| 3. Accounts Inserted {account_leaves_inserted:>13} | ||
| 4. Storage Downloaded {storage_leaves_downloaded:>13} {storage_per_second} storage slots/s | ||
| 5. Storage Inserted {storage_leaves_inserted:>13} | ||
| 6. Healing: {healed_accounts} accounts | ||
| 7. Healing: {healed_storages} storages | ||
| 8. Bytecodes Downloaded {bytecodes_downloaded:>13} {bytecodes_per_second} bytecodes/s | ||
|
Comment on lines
+277
to
+284
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a nit, but with this formatting we get: Could we make it look like this (aligning the unit names)? |
||
| ───────────────────────────────────────────────────────────────────────"# | ||
| ); | ||
| } | ||
| tokio::time::sleep(Duration::from_secs(10)).await; | ||
| tokio::time::sleep(Duration::from_secs(30)).await; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -404,7 +319,5 @@ fn format_duration(duration: Duration) -> String { | |
| let hours = total_seconds / 3600; | ||
| let minutes = (total_seconds % 3600) / 60; | ||
| let seconds = total_seconds % 60; | ||
| let milliseconds = total_seconds / 1000; | ||
|
|
||
| format!("{hours:02}h {minutes:02}m {seconds:02}s {milliseconds:02}ms") | ||
| format!("{hours:02}:{minutes:02}:{seconds:02}") | ||
| } | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually affect performance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's just visual modification (that is displayed every 30 secs).