Skip to content

refactor: consolidate AsyncLogger log enqueue paths - #3653

Merged
wwbmmm merged 1 commit into
apache:masterfrom
songgaoye:refactor/async-logger-perfect-forwarding
Oct 25, 2026
Merged

wwbmmm merged 1 commit into
apache:masterfrom
songgaoye:refactor/async-logger-perfect-forwarding

Conversation

@songgaoye

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: resolve

Problem Summary:

AsyncLogger::Log(const LogInfo&) and AsyncLogger::Log(LogInfo&&) duplicate
the same queue admission, shutdown, and synchronous fallback logic. Keeping
these paths separate makes future changes easier to diverge.

What is changed and the side effects?

Changed:

  • Consolidate the shared logging flow into an internal forwarding helper.
  • Keep lvalue inputs copied and rvalue inputs moved only after a log request is
    successfully allocated.
  • Preserve the existing synchronous fallback behavior when the logger is full,
    stopped, or allocation fails.

Side effects:

  • No intended behavioral change.

  • Performance effects:

    No expected material performance change. The rvalue path still moves the
    LogInfo into the queued request.

  • Breaking backward compatibility:

    No. This refactors private implementation details only.


Check List:

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.

🟢 Approval recommended

The focused refactor preserves existing behavior and has no identified blocking issues; builds and tests were not run.

No open issues 🎉

What changed in this PR

This PR consolidates AsyncLogger’s duplicated enqueue logic into a private forwarding helper while preserving existing logging behavior.

Changes:

  • Share queue admission, shutdown checks, and synchronous fallback logic between both Log overloads.
  • Preserve copying for lvalues and moving for rvalues only after successful request allocation.
File Description
src/​butil/​logging.cc Introduces LogInternal and copy/move enqueue helpers to remove duplicated control flow.

Review effort: Balanced

@wwbmmm
wwbmmm merged commit 1f5ff5b into apache:master Oct 25, 2026
29 checks passed
@songgaoye
songgaoye deleted the refactor/async-logger-perfect-forwarding branch October 25, 2026 10:29
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