Skip to content

perf: Deserialize received nodes once and only in job queue#7420

Open
bthomee wants to merge 6 commits into
developfrom
bthomee/jq
Open

perf: Deserialize received nodes once and only in job queue#7420
bthomee wants to merge 6 commits into
developfrom
bthomee/jq

Conversation

@bthomee

@bthomee bthomee commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

High Level Overview of Change

This change defers the deserialization of received nodes from the I/O thread to the job queue.

Context of Change

The changes here were originally developed as part of #6353, but it's better to pull them into a separate PR whose performance impact can then be evaluated individually.

Currently, received nodes in a TMGetLedger message are deserialized in the OnMessage handler, which runs in the I/O thread, purely as a sanity check before dispatching to the job queue. The nodes are then deserialized again after a thread picks up the task from the job queue. The proposed change will fully defer the deserialization and integrity checking to the job queue to free up to I/O thread and avoid double work.

One new addition is that the peer will now be charged a fee when sending more than Tuning::kSoftMaxReplyLimit nodes, which protects against a peer sending a request containing a very large number of node IDs. This limit was chosen because the existing code limits the number of nodes returned in the response to that amount* so there is little point in even sending more nodes to be processed.

*) The kSoftMaxReplyLimit is a soft limit; since a requested node ID can return multiple nodes in the response (via the getNodeFat function, which returns the node itself and its children up to a certain depth), the total number of nodes returned may be larger than the soft limit. However, it is hard limited via kHardMaxReplyLimit.

Copilot AI review requested due to automatic review settings June 6, 2026 13:31

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Behavior regression flagged inline: malformed SHAMap node IDs no longer trigger immediate disconnect, allowing fee-accumulation abuse via job-queue slots.

Review by Claude Sonnet 4.6 · Prompt: V15

Comment thread src/xrpld/overlay/detail/PeerImp.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR moves TMGetLedger SHAMap node-ID deserialization and integrity checking out of the I/O-thread onMessage handler and into the job-queue path, eliminating the prior “deserialize twice” behavior and reducing I/O-thread work during ledger-fetch traffic.

Changes:

  • Removed per-node SHAMapNodeID deserialization/validation from the I/O thread and deferred it into the JtLedgerReq job.
  • Updated processLedgerRequest to accept already-parsed std::vector<SHAMapNodeID> and use it when building TMLedgerData replies.
  • Minor internal refactors in node reply assembly (loop structure, variable naming, reserving capacity once).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/xrpld/overlay/detail/PeerImp.h Extends processLedgerRequest to accept a parsed std::vector<SHAMapNodeID> and adds required include.
src/xrpld/overlay/detail/PeerImp.cpp Defers node-id parsing to the job queue and adjusts processLedgerRequest to use the parsed node IDs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xrpld/overlay/detail/PeerImp.cpp
@bthomee bthomee added QE test desired RippleX QE Team should consider looking at this PR. and removed QE test desired RippleX QE Team should consider looking at this PR. labels Jun 6, 2026
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.3%. Comparing base (949887f) to head (ecd0136).

Files with missing lines Patch % Lines
src/xrpld/overlay/detail/PeerImp.cpp 0.0% 29 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #7420     +/-   ##
=========================================
- Coverage     82.3%   82.3%   -0.0%     
=========================================
  Files         1011    1011             
  Lines        76913   76919      +6     
  Branches      8964    8968      +4     
=========================================
- Hits         63336   63334      -2     
- Misses       13568   13576      +8     
  Partials         9       9             
Files with missing lines Coverage Δ
src/xrpld/overlay/detail/PeerImp.h 18.7% <ø> (ø)
src/xrpld/overlay/detail/PeerImp.cpp 5.6% <0.0%> (-<0.1%) ⬇️

... and 2 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Enforcement regression flagged inline — malformed node IDs no longer disconnect the peer.

Review by Claude Sonnet 4.6 · Prompt: V15

Comment thread src/xrpld/overlay/detail/PeerImp.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/xrpld/overlay/detail/PeerImp.cpp

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread src/xrpld/overlay/detail/PeerImp.cpp
Comment thread src/xrpld/overlay/detail/PeerImp.cpp
Comment thread src/xrpld/overlay/detail/PeerImp.cpp Outdated

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

@bthomee bthomee requested review from vlntb and ximinez June 6, 2026 23:14
@bthomee

bthomee commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

The performance evaluations can be found in https://gist.github.com/bthomee/3a0cb89a9709dc00b3f3e3bc0c329736. I included an AI generated summary of the findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

QE test desired RippleX QE Team should consider looking at this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants