Fix platform-specific performance regression in logtape.c.
authorJeff Davis <[email protected]>
Sun, 7 Jun 2020 16:14:24 +0000 (09:14 -0700)
committerJeff Davis <[email protected]>
Sun, 7 Jun 2020 16:25:55 +0000 (09:25 -0700)
Commit 24d85952 made a change that indirectly caused a performance
regression by triggering a change in the way GCC optimizes memcpy() on
some platforms.

The behavior seemed to contradict a GCC document, so I filed a report:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95556

This patch implements a narrow workaround which eliminates the
regression I observed. The workaround is benign enough that it seems
unlikely to cause a different regression on another platform.

Discussion: https://postgr.es/m/99b2eab335c1592c925d8143979c8e9e81e1575f[email protected]

src/backend/utils/sort/logtape.c

index 666a7c0e81cc4ed6457624093eccc707ddfa056c..4984f8ce50a4527a68a46bb263ca405155adf444 100644 (file)
@@ -782,7 +782,7 @@ LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
    Assert(lt->buffer_size == BLCKSZ);
    while (size > 0)
    {
-       if (lt->pos >= TapeBlockPayloadSize)
+       if (lt->pos >= (int) TapeBlockPayloadSize)
        {
            /* Buffer full, dump it out */
            long        nextBlockNumber;