Skip to content

Reduce host sector hashing#447

Merged
lukechampine merged 2 commits into
masterfrom
nate/reduce-hashing
Jun 23, 2026
Merged

Reduce host sector hashing#447
lukechampine merged 2 commits into
masterfrom
nate/reduce-hashing

Conversation

@n8mgr

@n8mgr n8mgr commented Jun 22, 2026

Copy link
Copy Markdown
Member

Calculating the sector root is a decent chunk of RPC write's round trip time and we currently effectively do it twice: once to calculate the root itself and another to calculate the subtrees in hostd. This deduplicates the hashing so we're not duplicating work.

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 reduces redundant sector hashing during RPCWriteSector handling by computing and reusing cached Merkle subtrees to derive the sector root, avoiding a second full-sector hash later in the storage pipeline.

Changes:

  • Extend the Sectors.StoreSector interface to accept precomputed sector subtrees.
  • Update RPCWriteSector server handling to compute CachedSectorSubtrees once and derive root from them.
  • Update tests/utilities to pass the new StoreSector arguments and use correct roots.

Reviewed changes

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

File Description
testutil/host.go Updates the in-memory sector store to match the new StoreSector signature.
rhp/v4/server.go Adds subtrees to the Sectors interface and reworks RPCWriteSector to compute root from cached subtrees.
rhp/v4/rpc_test.go Adjusts account-related tests to store/verify sectors using the computed root and subtrees.
.changeset/reduced_host_sector_hashing_in_rpcwritesector.md Adds a patch changeset documenting the behavior change.

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

Comment thread rhp/v4/server.go Outdated
Comment thread rhp/v4/server.go Outdated
@lukechampine lukechampine merged commit 4452016 into master Jun 23, 2026
31 of 34 checks passed
@lukechampine lukechampine deleted the nate/reduce-hashing branch June 23, 2026 00:58
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Sia Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants