Skip to content

perf: optimize compact progress query from O(m*n) to O(n+m)#35115

Merged
guanshengliang merged 9 commits into3.0from
feat/3.0/compact-update
Apr 20, 2026
Merged

perf: optimize compact progress query from O(m*n) to O(n+m)#35115
guanshengliang merged 9 commits into3.0from
feat/3.0/compact-update

Conversation

@xiao-77
Copy link
Copy Markdown
Contributor

@xiao-77 xiao-77 commented Apr 13, 2026

Replace per-vnode progress requests with dnode-level broadcast:

  • Add TDMT_DND_QUERY_COMPACT_PROGRESS message type
  • Add SDnodeQueryCompactProgressReq/Rsp structures and serialization
  • Refactor mndCompactSendProgressReq to broadcast to all dnodes
  • Add mndProcessDnodeCompactProgressRsp with hash-based O(n+m) lookup
  • Add vmProcessDnodeQueryCompactProgressReq to collect vnode progress
  • Register new message handler in mnode and vnode management queue

This optimization reduces the number of RPC calls from O(m*n) to O(n)
where m is the number of vnodes and n is the number of dnodes.

Reference: PR #35093

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Replace per-vnode progress requests with dnode-level broadcast:
- Add TDMT_DND_QUERY_COMPACT_PROGRESS message type
- Add SDnodeQueryCompactProgressReq/Rsp structures and serialization
- Refactor mndCompactSendProgressReq to broadcast to all dnodes
- Add mndProcessDnodeCompactProgressRsp with hash-based O(n+m) lookup
- Add vmProcessDnodeQueryCompactProgressReq to collect vnode progress
- Register new message handler in mnode and vnode management queue

This optimization reduces the number of RPC calls from O(m*n) to O(n)
where m is the number of vnodes and n is the number of dnodes.

Reference: PR #35093
Copilot AI review requested due to automatic review settings April 13, 2026 06:23
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new mechanism for querying compaction progress at the dnode level, replacing the previous vnode-by-vnode query approach. It adds new message types (TDMT_DND_QUERY_COMPACT_PROGRESS), serialization logic, and handlers on both the dnode and mnode sides to efficiently collect and update progress information. Review feedback identifies a potential memory leak when RPC requests fail, suggests an optimization to skip processing when no vnode updates are present, and highlights a potential safety issue with string formatting during debug logging.

Comment thread source/dnode/mnode/impl/src/mndCompact.c
Comment thread source/dnode/mnode/impl/src/mndCompact.c
Comment thread source/dnode/mnode/impl/src/mndCompact.c
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 optimizes compaction progress collection by replacing per-vnode progress RPCs with a single broadcast per dnode, reducing RPC fanout while keeping progress updates accurate and efficient.

Changes:

  • Introduces TDMT_DND_QUERY_COMPACT_PROGRESS request/response flow and corresponding message (de)serialization.
  • Refactors mnode progress polling to broadcast to all dnodes and processes replies using a hash-based lookup to avoid nested scans.
  • Adds vnode-mgmt handling to aggregate per-vnode compact progress into a single dnode-level response.

Reviewed changes

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

Show a summary per file
File Description
source/dnode/mnode/impl/src/mndCompact.c Broadcasts progress queries to dnodes and processes aggregated dnode responses with hash-based matching.
source/dnode/mnode/impl/inc/mndCompact.h Exposes new compact progress response handler (and adds a new DB-name API declaration).
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c Routes the new dnode compact-progress query message type to a vnode-mgmt handler.
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c Implements the dnode request handler that aggregates compact progress across local vnodes.
source/common/src/msg/tmsg.c Adds serializers/deserializers for the new dnode compact-progress req/rsp.
include/common/tmsgdef.h Registers the new message type.
include/common/tmsg.h Declares new req/rsp structs and (de)serialization APIs.

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

Comment thread source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
Comment thread source/dnode/mnode/impl/inc/mndCompact.h Outdated
Copilot AI review requested due to automatic review settings April 13, 2026 08:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 3 comments.


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

Comment thread source/dnode/mnode/impl/src/mndCompact.c
Comment thread source/common/src/msg/tmsg.c
Comment thread source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 13, 2026 09:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 3 comments.


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

Comment thread source/dnode/mgmt/mgmt_vnode/src/vmWorker.c Outdated
Comment thread source/dnode/mgmt/mgmt_vnode/src/vmHandle.c Outdated
Comment thread source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 14, 2026 01:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 9 out of 9 changed files in this pull request and generated 1 comment.


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

Comment thread source/dnode/mnode/impl/src/mndCompact.c
@guanshengliang guanshengliang merged commit 209cb15 into 3.0 Apr 20, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants