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

Visualisation logging for sync batch states #6034

Merged
merged 10 commits into from
Jul 29, 2024

Conversation

AgeManning
Copy link
Member

I have been writing up logic about how sync works and also debugging some sync issues locally.

I thought it would be an improvement to have a visual representation of a current chain state, to help see where abouts the progress of a chain is at any given point from just eyeballing the logs.

I set a few icons to represent different batch states:

    /// The current icons are:
    /// - Empty/Uninitialized: 
    /// - Downloading: 󰦗
    /// - Awaiting Download: 󰝤
    /// - Awaiting Validation: 󰦖
    /// - Failed: 
    /// - AwaitingProcessing: 

These are from nerd-fonts and should appear for any os with the fonts installed.

These changes produce a small log when we are updating the chain state showing the current state of our block downloading buffer.

Here are some example logs I've run on a mainnet head sync:

Jul 02 04:48:30.068 DEBG Requesting batch                        batch_state: [󰝤 ], start_slot: 9422560, end_slot: 9422591, downloaded: 0, processed: 0, processed_no_penalty: 0, state: Downloading(16Uiu2HAmCJEcww2BZ7Cj93Rvzkj8cf19pAmi2kiFw4qj9X5vw7AU, 13), batch_ty: blocks_and_blobs, epoch: 294455, chain: 12325625451770947895, service: range_sync, service: sync
Jul 02 04:48:30.119 DEBG Requesting batch                        batch_state: [󰦗 󰝤 ], start_slot: 9422592, end_slot: 9422623, downloaded: 0, processed: 0, processed_no_penalty: 0, state: Downloading(16Uiu2HAmFVBES8qsTwVeAM6Tv6V8qexeGZnkGKkTGhsRfjQnKbZt, 14), batch_ty: blocks_and_blobs, epoch: 294456, chain: 12325625451770947895, service: range_sync, service: sync
Jul 02 04:48:30.119 DEBG Requesting batch                        batch_state: [󰦗 󰝤 ], start_slot: 9422592, end_slot: 9422623, downloaded: 1, processed: 0, processed_no_penalty: 0, state: Downloading(16Uiu2HAmCJEcww2BZ7Cj93Rvzkj8cf19pAmi2kiFw4qj9X5vw7AU, 15), batch_ty: blocks_and_blobs, epoch: 294456, chain: 12325625451770947895, service: range_sync, service: sync
Jul 02 04:48:33.907 DEBG Requesting batch                        batch_state: [  󰦗 󰝤 ], start_slot: 9422624, end_slot: 9422655, downloaded: 0, processed: 0, processed_no_penalty: 0, state: Downloading(16Uiu2HAmUhvmM4z7XryDrMyQXVUrHB2AWMfaAPcmS5qQRoTSkzs7, 16), batch_ty: blocks_and_blobs, epoch: 294457, chain: 11891774074394069546, service: range_sync, service: sync
Jul 02 04:48:33.910 DEBG Batch downloaded                        awaiting_batches: 1, batch_state: [   󰦗 ], blocks: 0, epoch: 294456, chain: 11891774074394069546, service: range_sync, service: sync
Jul 02 04:48:36.055 DEBG Batch downloaded                        awaiting_batches: 2, batch_state: [     ], blocks: 16, epoch: 294457, chain: 11891774074394069546, service: range_sync, service: sync
Jul 02 04:48:36.462 DEBG Requesting batch                        batch_state: [󰦗 󰦗 󰝤 ], start_slot: 9422624, end_slot: 9422655, downloaded: 0, processed: 0, processed_no_penalty: 0, state: Downloading(16Uiu2HAmRtTvtezhpWsSBnRBVa29KsQf6Sb9sPA2uAqyUvnNSa6t, 17), batch_ty: blocks_and_blobs, epoch: 294457, chain: 12325625451770947895, service: range_sync, service: sync

It's not as handy as I had originally expected because the buffer is a moving window, but it is useful to show where sync might be stalling, how many we are currently downloading and what bottlenecks etc.

A more holistic approach is probably a proper sync grafana dash.

@jimmygchen
Copy link
Member

jimmygchen commented Jul 3, 2024

The visualization is nice!! 🔥

I couldn't get it to render on my terminal though, I've tried a few built-in fonts but they don't render, looks like I might have to install something from nerd-fonts?

I tried emojis and they work well (on my machine) - think it might be worth considering since some of them have been part of the Unicode standard for a while and should have wide OS support. I've only tested on MacOS though ;)

@dapplion
Copy link
Collaborator

dapplion commented Jul 3, 2024

Screenshot 2024-07-03 at 10 51 42

is it expected for icons to not render on the browser?

@ackintosh
Copy link
Member

I installed the 0xProto font on my Ubuntu machine and saw the following icons:

image

Using emojis seems like a good idea. 💡

@AgeManning
Copy link
Member Author

Yeah sorry. The fonts I used aren't widely used.

If someone can suggest some good emoji's maybe we can do with that.

@jimmygchen
Copy link
Member

Some options:

fn visualize(&self) -> &'static str {
    match self {
        BatchState::Downloading(_, _) => "⏬",
        BatchState::Processing(_) => "🔄",
        BatchState::AwaitingValidation(_) => "⏳",
        BatchState::AwaitingDownload => "📥",
        BatchState::Failed => "❌",
        BatchState::AwaitingProcessing(_, _) => "🕓",
        BatchState::Poisoned => "💀",
    }
}

Face emojis from neutral to happy face

fn visualize(&self) -> &'static str {
    match self {
        BatchState::AwaitingDownload => "😐",
        BatchState::Downloading(_, _) => "🙂",
        BatchState::AwaitingProcessing(_, _) => "😊",
        BatchState::Processing(_) => "😃",
        BatchState::AwaitingValidation(_) => "😁",
        BatchState::Failed => "😞",
        BatchState::Poisoned => "😵",
    }
}

@AgeManning
Copy link
Member Author

Awesome thanks. I replaced them with emoji's now.

@dapplion
Copy link
Collaborator

Not sure how I feel to have debug logs full of emojis now.. haha

This batch state codes will be read by a small minority of devs who could memorize the meaning of a few letters. Plus there are ordering rules of states that reduce the max possible combination of states. ASCII has a bunch of disctict symbols that can de used.

For example:

  • Downloading -> D
  • Processing -> P
  • AwaitingX -> lowercase x
  • Failed -> F
  • Poisoned -> P
fn visualize(&self) -> &'static str {
    match self {
        BatchState::Downloading(_, _) => "D",
        BatchState::Processing(_) => "P",
        BatchState::AwaitingValidation(_) => "v",
        BatchState::AwaitingDownload => "d",
        BatchState::Failed => "F",
        BatchState::AwaitingProcessing(_, _) => "p",
        BatchState::Poisoned => "X",
    }
}

@AgeManning
Copy link
Member Author

Yeah fair. I'm not sold on this PR and if people don't find it useful, happy to ditch it.

The reason I built it was, i saw a couple of times sync being stalled and it was kind of pain to track down and figure out what we were waiting on this (because the batches are all numbers).

Happy to switch to text for the states. If i get a few thumbs on this, then I'll consider this PR useful, switch to text and merge down.

If not many thumbs <3, i'll close this PR

@jimmygchen
Copy link
Member

Gave you both my thumbs 👍

@dapplion
Copy link
Collaborator

The reason I built it was, i saw a couple of times sync being stalled and it was kind of pain to track down and figure out what we were waiting on this (because the batches are all numbers).

Sync lookup has now a gadget to detect when it gets stuck and drops a nice long report to logs. This has been the key to debug stalls in minutes instead of hours. We could do the same for other syncs

Copy link
Member

@jimmygchen jimmygchen left a comment

Choose a reason for hiding this comment

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

Added some minor comments, otherwise looks good to me!

Copy link
Collaborator

@dapplion dapplion left a comment

Choose a reason for hiding this comment

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

There's a Cargo.lock diff

@AgeManning
Copy link
Member Author

@Mergifyio queue

Copy link

mergify bot commented Jul 25, 2024

queue

🛑 Branch protection settings are not validated anymore

Branch protection is enabled and is preventing Mergify to merge the pull request. Mergify will merge when branch protection settings validate the pull request once again. (detail: 1 review requesting changes and 1 approving review by reviewers with write access.)

mergify bot added a commit that referenced this pull request Jul 25, 2024
@jimmygchen jimmygchen added the ready-for-merge This PR is ready to merge. label Jul 25, 2024
@jimmygchen
Copy link
Member

@mergify requeue

Copy link

mergify bot commented Jul 25, 2024

requeue

✅ This pull request will be re-embarked automatically

The followup queue command will be automatically executed to re-embark the pull request

Copy link

mergify bot commented Jul 25, 2024

queue

🛑 The pull request has been removed from the queue default

The queue conditions cannot be satisfied due to failing checks.

You can take a look at Queue: Embarked in merge queue check runs for more details.

In case of a failure due to a flaky test, you should first retrigger the CI.
Then, re-embark the pull request into the merge queue by posting the comment
@mergifyio refresh on the pull request.

mergify bot added a commit that referenced this pull request Jul 25, 2024
@jimmygchen
Copy link
Member

@mergify requeue

Copy link

mergify bot commented Jul 25, 2024

requeue

✅ This pull request will be re-embarked automatically

The followup queue command will be automatically executed to re-embark the pull request

Copy link

mergify bot commented Jul 25, 2024

queue

🛑 Branch protection settings are not validated anymore

Branch protection is enabled and is preventing Mergify to merge the pull request. Mergify will merge when branch protection settings validate the pull request once again. (detail: 1 review requesting changes and 1 approving review by reviewers with write access.)

@AgeManning
Copy link
Member Author

@Mergifyio refresh

Copy link

mergify bot commented Jul 29, 2024

refresh

✅ Pull request refreshed

@jimmygchen
Copy link
Member

@mergify requeue

Copy link

mergify bot commented Jul 29, 2024

requeue

✅ This pull request will be re-embarked automatically

The followup queue command will be automatically executed to re-embark the pull request

Copy link

mergify bot commented Jul 29, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at a3b1ef3

mergify bot added a commit that referenced this pull request Jul 29, 2024
@mergify mergify bot merged commit a3b1ef3 into sigp:unstable Jul 29, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge. UX-and-logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants