diff --git a/engine.c b/engine.c index bbf49ce..35cc14c 100644 --- a/engine.c +++ b/engine.c @@ -430,7 +430,7 @@ ptrackCheckpoint(void) if (j == PTRACK_BUF_SIZE) { - int writesz = sizeof(buf); /* Up to ~2 GB for buffer size seems + size_t writesz = sizeof(buf); /* Up to ~2 GB for buffer size seems * to be more than enough, so never * going to overflow. */ @@ -439,7 +439,7 @@ ptrackCheckpoint(void) * takes into account all paddings for us. */ ptrack_write_chunk(ptrack_tmp_fd, &crc, (char *) buf, writesz); - elog(DEBUG5, "ptrack checkpoint: i " UINT64_FORMAT ", j " UINT64_FORMAT ", writesz %d PtrackContentNblocks " UINT64_FORMAT, + elog(DEBUG5, "ptrack checkpoint: i " UINT64_FORMAT ", j " UINT64_FORMAT ", writesz %zu PtrackContentNblocks " UINT64_FORMAT, i, j, writesz, (uint64) PtrackContentNblocks); j = 0; @@ -449,10 +449,10 @@ ptrackCheckpoint(void) /* Write if anythig left */ if ((i + 1) % PTRACK_BUF_SIZE != 0) { - int writesz = sizeof(pg_atomic_uint64) * j; + size_t writesz = sizeof(pg_atomic_uint64) * j; ptrack_write_chunk(ptrack_tmp_fd, &crc, (char *) buf, writesz); - elog(DEBUG5, "ptrack checkpoint: final i " UINT64_FORMAT ", j " UINT64_FORMAT ", writesz %d PtrackContentNblocks " UINT64_FORMAT, + elog(DEBUG5, "ptrack checkpoint: final i " UINT64_FORMAT ", j " UINT64_FORMAT ", writesz %zu PtrackContentNblocks " UINT64_FORMAT, i, j, writesz, (uint64) PtrackContentNblocks); } diff --git a/engine.h b/engine.h index 5dbd6b8..34cf15f 100644 --- a/engine.h +++ b/engine.h @@ -31,7 +31,13 @@ /* Used for atomical crash-safe update of ptrack.map */ #define PTRACK_PATH_TMP "global/ptrack.map.tmp" -#define PTRACK_BUF_SIZE 1000 +/* + * 8k of 64 bit LSNs is 64 KB, which looks like a reasonable + * buffer size for disk writes. On fast NVMe SSD it gives + * around 20% increase in ptrack checkpoint speed compared + * to PTRACK_BUF_SIZE == 1000, i.e. 8 KB writes. + */ +#define PTRACK_BUF_SIZE ((uint64) 8000) /* Ptrack magic bytes */ #define PTRACK_MAGIC "ptk"