Hoist the PlanExecutor lookup out of the CursorStage batch loop

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0, 9.0.0-rc3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • v9.0
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Overview

      CursorStage::pullDataFromExecutor() reached the PlanExecutor through a shared_ptr and then a unique_ptr on every loop iteration. The virtual getNextDocument() call is opaque to the compiler, so it cannot hoist the loads itself.

      Scope of Work

      * src/mongo/db/exec/agg/cursor_stage.cpp — read _sharedState->exec once before the loop

      Notes

      The loop already dereferenced _sharedState->exec unconditionally with no null check, so it relied on exec not being reset mid-loop. Only cleanupExecutor() resets it, and this loop never reaches it, so caching the raw pointer adds no new assumption.

      Acceptance Criteria

      * No behaviour change

            Assignee:
            Catalin Sumanaru
            Reporter:
            Catalin Sumanaru
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: