Skip to content

perf: optimize instrumentation in hot paths#890

Merged
thlorenz merged 4 commits intomasterfrom
thlorenz/logs-aperture-chainlink-optimization
Mar 2, 2026
Merged

perf: optimize instrumentation in hot paths#890
thlorenz merged 4 commits intomasterfrom
thlorenz/logs-aperture-chainlink-optimization

Conversation

@thlorenz
Copy link
Copy Markdown
Collaborator

@thlorenz thlorenz commented Jan 24, 2026

Summary

Optimizes instrumentation overhead in hot paths by avoiding pubkey/signature stringification when accounts are already in the local bank. The transaction signature is now carried through the call chain and only stringified in the cold path (when actually fetching from chain).

CLOSES: #867

Details

Hot Path Optimization

Removed eager signature/pubkey stringification from the hot path functions:

  • send_transaction: Changed to #[instrument(skip_all)], removed .record() call
  • ensure_transaction_accounts: Changed to #[instrument(skip_all)]
  • read_account_with_ensure: Changed to #[instrument(skip_all)]

Cold Path Signature Propagation

Extended AccountFetchOrigin::SendTransaction to carry the transaction signature:

  • Changed from unit variant to SendTransaction(Signature)
  • Added signature() accessor method
  • Signature is a 64-byte memcpy (~1ns) vs base58 stringification (~500ns + heap alloc)

In fetch_and_clone_accounts (cold path), the signature is recorded on the span so it appears in all logs during chain fetch operations.

Documentation

Added explanatory comments to cold path functions in chain_laser_actor.rs, chain_pubsub_actor.rs, and subscription_reconciler.rs noting that pubkey stringification is acceptable there since network I/O dwarfs the cost.

Summary by CodeRabbit

  • Improvements
    • Enhanced transaction signature tracking throughout account operations for improved visibility into transaction flows across system components.
    • Optimized logging instrumentation on core transaction and account handling methods to improve system performance while maintaining operational observability.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 24, 2026

Manual Deploy Available

You can trigger a manual deploy of this PR branch to testnet:

Deploy to Testnet 🚀

Alternative: Comment /deploy on this PR to trigger deployment directly.

⚠️ Note: Manual deploy requires authorization. Only authorized users can trigger deployments.

Comment updated automatically when the PR is synchronized.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ee47fe and c25bdcf.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • magicblock-aperture/src/requests/http/mod.rs
  • magicblock-aperture/src/requests/http/send_transaction.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/mod.rs
  • magicblock-chainlink/src/chainlink/mod.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs
  • magicblock-chainlink/src/remote_account_provider/subscription_reconciler.rs
  • magicblock-metrics/Cargo.toml
  • magicblock-metrics/src/metrics/types.rs

📝 Walkthrough

Walkthrough

This PR optimizes tracing instrumentation overhead by reducing field-level logging in the magicblock-aperture request path while deferring detailed signature logging to the magicblock-chainlink fetch_cloner phase where accounts are being retrieved. Changes include converting per-field instrumentation to skip_all in aperture layer methods, removing explicit signature recording from send_transaction, and deferred recording of transaction signatures in fetch_cloner. The AccountFetchOrigin::SendTransaction variant is updated to carry a Signature payload to support passing transaction signature context through the chain. Comments explaining acceptable overhead on cold paths are added for clarity.

Assessment against linked issues

Objective Addressed Explanation
Reduce pubkey stringification overhead in aperture → chainlink path before reaching account fetch phase [#867]
Defer stringification overhead to account fetch phase where it is negligible [#867]
Be diligent about where instrumentation overhead is acceptable [#867]

Suggested reviewers

  • GabrielePicco
  • bmuddha
  • Dodecahedr0x
✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch thlorenz/logs-aperture-chainlink-optimization

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@thlorenz thlorenz requested a review from bmuddha January 24, 2026 22:13
Copy link
Copy Markdown
Collaborator

@bmuddha bmuddha left a comment

Choose a reason for hiding this comment

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

LGTM, with minor nit

Comment thread magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs Outdated
@thlorenz thlorenz force-pushed the thlorenz/logs-aperture-chainlink-optimization branch from 6ee47fe to c25bdcf Compare March 2, 2026 08:32
@thlorenz thlorenz merged commit 8274f64 into master Mar 2, 2026
18 checks passed
@thlorenz thlorenz deleted the thlorenz/logs-aperture-chainlink-optimization branch March 2, 2026 09:15
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.

perf: remove overhead caused by tracing instrumentation

2 participants