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

feat: add latency metrics to batcher #1578

Merged
merged 10 commits into from
Dec 10, 2024
Merged

Conversation

avilagaston9
Copy link
Collaborator

@avilagaston9 avilagaston9 commented Dec 4, 2024

Add Latency Metrics to Batcher

Description

Adds the following metrics to the Batcher:

  • S3 Latency: Measures the time it takes to upload the batch to S3.
  • CreateNewTask Latency: Measures the time the CreateNewTask function takes. It is broken down into two:
    • create_new_task: Time it takes to send the new task to Ethereum.
    • cancel_new_task: Time it takes to cancel the new task, in case the receipt is not found.

Note

The time shown is always the latest one. cancel_new_task is set to zero since sometimes the function is not executed.

image

Note

It always takes 7 secs to get a receipt from anvil.

How to Test

  1. Start Anvil:
make anvil_start_with_block_time
  1. Start the Batcher:
make batcher_start_local
  1. Start the metrics:
make run_metrics
  1. Start sending proofs:
make batcher_send_burst_groth16
  1. Go to localhost:3000 and watch the System Data dashboard.

You can also edit the Batcher code to emit some cancel_new_task events:

  1. Edit the batcher/aligned-batcher/src/lib.rs file in line 1569 as follows:
Ok(receipt) => {
    if let Err(e) = self
        .telemetry
        .task_sent(&hex::encode(batch_merkle_root), receipt.transaction_hash)
        .await
    {
        warn!("Failed to send task status to telemetry: {:?}", e);
    }
    if start.elapsed().as_millis() % 2 == 0 {
        self.cancel_create_new_task_tx(fee_params.gas_price).await;
    }
    Ok(receipt)
}

Type of change

  • New feature

Checklist

  • “Hotfix” to testnet, everything else to staging
  • Linked to Github Issue
  • This change depends on code or research by an external entity
    • Acknowledgements were updated to give credit
  • Unit tests added
  • This change requires new documentation.
    • Documentation has been added/updated.
  • This change is an Optimization
    • Benchmarks added/run
  • Has a known issue
  • If your PR changes the Operator compatibility (Ex: Upgrade prover versions)
    • This PR adds compatibility for operator for both versions and do not change batcher/docs/examples
    • This PR updates batcher and docs/examples to the newer version. This requires the operator are already updated to be compatible

Copy link

github-actions bot commented Dec 4, 2024

Changes to gas cost

Generated at commit: 34ad21c91e46eec8b5e2dc917ad519f5c4ef144e, compared to commit: 8b6ef0c71f65d1233d392c2d58f2f1442ba27fab

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
AlignedLayerServiceManager createNewTask +302 ❌ +0.40%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
AlignedLayerServiceManager 5,231,234 (0) createNewTask
receive
56,083 (0)
23,317 (0)
0.00%
0.00%
76,066 (+302)
46,915 (+373)
+0.40%
+0.80%
76,217 (-24)
47,195 (0)
-0.03%
0.00%
77,030 (0)
47,195 (0)
0.00%
0.00%
256 (0)
256 (0)

@avilagaston9 avilagaston9 changed the base branch from testnet to staging December 4, 2024 21:05
@avilagaston9 avilagaston9 marked this pull request as ready for review December 4, 2024 21:52
@avilagaston9 avilagaston9 self-assigned this Dec 5, 2024
Copy link
Contributor

@uri-99 uri-99 left a comment

Choose a reason for hiding this comment

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

also i would separate the latencies in grafana in a different section

Copy link
Collaborator

@JulianVentura JulianVentura left a comment

Choose a reason for hiding this comment

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

Code looks fine and seems to work as expected. I'm just leaving a comment because of curiosity

batcher/aligned-batcher/src/lib.rs Show resolved Hide resolved
@JuArce JuArce added this pull request to the merge queue Dec 10, 2024
Merged via the queue into staging with commit 5b6aca1 Dec 10, 2024
3 checks passed
@JuArce JuArce deleted the feat-batcher-latency-metrics branch December 10, 2024 18:58
PatStiles pushed a commit that referenced this pull request Jan 10, 2025
Co-authored-by: Marcos Nicolau <marcosnicolau@lambdaclass.com>
PatStiles pushed a commit that referenced this pull request Jan 10, 2025
Co-authored-by: Marcos Nicolau <marcosnicolau@lambdaclass.com>
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.

7 participants