Skip to content

MDEV-39490 Inline the disabled fast path of Opt_trace_start::init()#5430

Merged
iMineLink merged 1 commit into
10.11from
MDEV-39490
Jul 22, 2026
Merged

MDEV-39490 Inline the disabled fast path of Opt_trace_start::init()#5430
iMineLink merged 1 commit into
10.11from
MDEV-39490

Conversation

@iMineLink

Copy link
Copy Markdown
Contributor

Optimizer trace is disabled by default, yet init() was out of line, so every statement paid a call plus a full prologue/epilogue only to test FLAG_ENABLED and return.

Move the FLAG_ENABLED test into an inline init() so the disabled path collapses to a flag load and a predicted-not-taken branch. The enabled path setup stays out of line in the new init_traceable(). Behaviour and the init() signature are unchanged.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI 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.

Pull request overview

This PR optimizes the common “optimizer trace disabled” path by inlining Opt_trace_start::init() so most statements avoid an out-of-line call overhead, while keeping the enabled/traceable setup in a separate out-of-line helper.

Changes:

  • Inlined Opt_trace_start::init() in sql/opt_trace.h with a fast FLAG check and delegation to the slow path.
  • Introduced Opt_trace_start::init_traceable() to hold the enabled-path setup previously in init().
  • Updated sql/opt_trace.cc accordingly by moving the remaining traceability checks and setup into init_traceable().

Reviewed changes

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

File Description
sql/opt_trace.h Inlines Opt_trace_start::init() to make the disabled trace path a cheap inline flag check.
sql/opt_trace.cc Adds init_traceable() implementation to keep the enabled-path work out of line.

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

Comment thread sql/opt_trace.cc

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors Opt_trace_start::init to optimize the common case where optimizer tracing is disabled. It inlines a fast-path check in sql/opt_trace.h and moves the full context setup to a new slow-path helper, init_traceable, in sql/opt_trace.cc. The feedback suggests removing the redundant assignment traceable = FALSE; inside the inlined init function, as traceable is already initialized to false in the constructor, which would further optimize the fast path by avoiding an unnecessary store instruction.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread sql/opt_trace.h Outdated
Optimizer trace is disabled by default, yet init() was out of line, so
every statement paid a call plus a full prologue/epilogue only to test
FLAG_ENABLED and return.

Move the FLAG_ENABLED test into an inline init() so the disabled path
collapses to a flag load and a predicted-not-taken branch. The enabled
path setup stays out of line in the new init_traceable(). traceable is
left to the constructor and only asserted, not re-stored, in init(), so
no store lands on the disabled hot path. Behaviour and the init()
signature are unchanged.

@mariadb-RexJohnston mariadb-RexJohnston left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other than maybe chucking in an inline hint in the object definition, this looks fine.

@iMineLink

Copy link
Copy Markdown
Contributor Author

:D right, the inline hint would have made the intent more explicit, but it should be redundant since the method definition is provided inside the class definition in the header. Thanks for reviewing.

@iMineLink
iMineLink merged commit 4d1bb27 into 10.11 Jul 22, 2026
15 of 17 checks passed
@iMineLink
iMineLink deleted the MDEV-39490 branch July 22, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants