Make SBE hash lookup tests more efficient

XMLWordPrintableJSON

    • Query Execution
    • Fully Compatible
    • v8.2
    • QE 2025-10-27
    • 0
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      BF-39962 is about a test failure in which the db_sbe_test unit test ran into a timeout.
      The slowest tests in the run were HashLookupStageTest::BasicTests and HashLookupUnwindStageTest::BasicTests.

      It seems that these tests use several std::ostringstream instances to build up large strings in memory.
      The code that builds the streams flushes the output buffer backing those streams often and unnecessarily using std::endl. According to documentation this worsens performance and should be avoided if not necessary.
      The usage of std::endl can be avoided here and replaced with simple newline characters.

      The tests also copy the strings backing the streams unnecessarily for comparing them, using the str() function of the stream, which copies to underlying stream buffer into an std::string.
      Example:

          std::stringstream firstStream;
          StageResultsPrinters::make(firstStream, printOptions).printStageResults(ctx, slotNames, stage);
          std::string firstStr = firstStream.str();
      ...
          std::stringstream secondStream;
          StageResultsPrinters::make(secondStream, printOptions).printStageResults(ctx, slotNames, stage);
          std::string secondStr = secondStream.str();
          ASSERT_EQ(firstStr, secondStr);
      

      The calls to str() can be avoided here, and instead the view() function can be used for comparison. view() creates a view into the stream buffer, which is much more efficient than creating an std::string.
      view() is only available in C++20, so we need to check if it's supported by all compilers on all platforms we use.

            Assignee:
            Jan Steemann
            Reporter:
            Jan Steemann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: