MDEV-39490 Inline the disabled fast path of Opt_trace_start::init()#5430
Conversation
|
|
There was a problem hiding this comment.
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()insql/opt_trace.hwith a fast FLAG check and delegation to the slow path. - Introduced
Opt_trace_start::init_traceable()to hold the enabled-path setup previously ininit(). - Updated
sql/opt_trace.ccaccordingly by moving the remaining traceability checks and setup intoinit_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.
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
Other than maybe chucking in an inline hint in the object definition, this looks fine.
|
: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. |
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.