Skip to content

feat(fsmonitor): use recvmmsg for batch event receiving - #283

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
wangrong1069:agent/pms-bug-bot/05976ca37725
Oct 13, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/snipefrom
wangrong1069:agent/pms-bug-bot/05976ca37725

Conversation

@wangrong1069

@wangrong1069 wangrong1069 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

feat(fsmonitor): use recvmmsg for batch event receiving

Replace single-packet recv() with recvmmsg() to drain up to 64
fs_event messages per syscall, reducing system call overhead during
high-event bursts and lowering the risk of dispatcher buffer overflow.

The iovec and mmsghdr arrays are pre-allocated as member variables
and initialized in the VfsSocketReader constructor. Before each
recvmmsg batch call, the iovec pointers are reset because the kernel
may advance them while consuming messages.

The socket is already non-blocking (SOCK_NONBLOCK set by the
dispatcher's socketpair), so flag 0 is used instead of MSG_DONTWAIT.

Event handling logic (path resolution, mount refresh deferral,
pending batch coalescing) is unchanged.

Summary by Sourcery

Enhancements:

  • Batch filesystem monitor event reception to process up to 64 messages per system call, reducing overhead and improving resilience during event bursts.

@sourcery-ai

sourcery-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

Replaces single-message recv() draining with nonblocking recvmmsg() batches of up to 64 fs_event messages, reducing syscall overhead during bursts while retaining the existing event-processing semantics.

Sequence diagram for batched filesystem event receiving

sequenceDiagram
    participant Dispatcher
    participant Reader as VfsSocketReader
    participant Kernel
    participant Watcher

    Dispatcher->>Kernel: send fs_event messages
    Kernel-->>Dispatcher: socketpair delivery
    Reader->>Kernel: recvmmsg(socketFd, msgHeaders, 64, 0, nullptr)
    Kernel-->>Reader: up to 64 fs_event messages
    loop each received message
        Reader->>Reader: resolveAndFilterFullPath(deviceId, event.path)
        Reader->>Reader: append pendingBatch
    end
    Reader->>Watcher: flushPendingBatch()
    Reader->>Kernel: recvmmsg(...)
    Kernel-->>Reader: EAGAIN
Loading

File-Level Changes

Change Details Files
Batch socket reads to process multiple filesystem events per system call.
  • Adds preallocated receive buffers, iovec entries, and message headers for 64 messages.
  • Resets iovec state before each recvmmsg call and uses the existing nonblocking socket with flags set to zero.
  • Iterates over each received message while preserving existing validation, path resolution, mount deferral, and event coalescing behavior.
src/index/fsmonitor/vfsmonitorwatcher.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Replace single-packet recv() with recvmmsg() to drain up to 64
fs_event messages per syscall, reducing system call overhead during
high-event bursts and lowering the risk of dispatcher buffer overflow.

The iovec and mmsghdr arrays are pre-allocated as member variables
and initialized in the VfsSocketReader constructor. Before each
recvmmsg batch call, the iovec pointers are reset because the kernel
may advance them while consuming messages.

The socket is already non-blocking (SOCK_NONBLOCK set by the
dispatcher's socketpair), so flag 0 is used instead of MSG_DONTWAIT.

Event handling logic (path resolution, mount refresh deferral,
pending batch coalescing) is unchanged.
@wangrong1069
wangrong1069 force-pushed the agent/pms-bug-bot/05976ca37725 branch from dd0fa6b to 473dd27 Compare October 13, 2026 06:06
@wangrong1069

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 09abcf2 into linuxdeepin:develop/snipe Oct 13, 2026
17 checks passed
@wangrong1069
wangrong1069 deleted the agent/pms-bug-bot/05976ca37725 branch October 13, 2026 12:45
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, wangrong1069

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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.

3 participants