mirror of
https://github.com/pgvector/pgvector.git
synced 2026-12-04 00:08:30 +00:00
Improved vacuuming progress for HNSW [skip ci]
This commit is contained in:
1 parent
0c329a5aa2
commit
effd6783ae
1 file changed
+18
-12
+18
-12
@@ -378,6 +378,22 @@ RepairGraphEntryPoint(HnswVacuumState * vacuumstate)
|
||||
MemoryContextReset(vacuumstate->tmpCtx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update progress
|
||||
*
|
||||
* No need to update total blocks since new blocks are quick
|
||||
*/
|
||||
static inline void
|
||||
UpdateProgress(int64 scannedBlocks, BlockNumber totalBlocks)
|
||||
{
|
||||
#if PG_VERSION_NUM >= 200000
|
||||
pgstat_progress_update_param(PROGRESS_SCAN_BLOCKS_DONE, Min(scannedBlocks, totalBlocks));
|
||||
#else
|
||||
if (scannedBlocks == totalBlocks || (scannedBlocks % 1000 == 0 && scannedBlocks < totalBlocks))
|
||||
elog(DEBUG1, "hnsw vacuum progress: %.1f%%", 100.0 * Min(scannedBlocks, totalBlocks) / totalBlocks);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Repair graph for all elements
|
||||
*/
|
||||
@@ -388,6 +404,7 @@ RepairGraph(HnswVacuumState * vacuumstate)
|
||||
BufferAccessStrategy bas = vacuumstate->bas;
|
||||
BlockNumber blkno = HNSW_HEAD_BLKNO;
|
||||
BlockNumber totalBlocks = InvalidBlockNumber; /* avoid compiler warning */
|
||||
int64 scannedBlocks = HNSW_HEAD_BLKNO;
|
||||
#if PG_VERSION_NUM >= 200000
|
||||
bool reportProgress = vacuumstate->info->report_progress;
|
||||
#else
|
||||
@@ -510,19 +527,8 @@ RepairGraph(HnswVacuumState * vacuumstate)
|
||||
MemoryContextReset(vacuumstate->tmpCtx);
|
||||
|
||||
/* Update progress */
|
||||
/* No need to update total blocks since new blocks are quick */
|
||||
if (reportProgress)
|
||||
{
|
||||
BlockNumber currentBlocks = BlockNumberIsValid(blkno) && blkno < totalBlocks ? blkno : totalBlocks;
|
||||
|
||||
#if PG_VERSION_NUM >= 200000
|
||||
pgstat_progress_update_param(PROGRESS_SCAN_BLOCKS_DONE, currentBlocks);
|
||||
#else
|
||||
/* Check blkno instead of currentBlocks to avoid extra logging */
|
||||
if (!BlockNumberIsValid(blkno) || (blkno % 1000 == 0 && blkno < totalBlocks))
|
||||
elog(DEBUG1, "hnsw vacuum progress: %.1f%%", 100.0 * currentBlocks / totalBlocks);
|
||||
#endif
|
||||
}
|
||||
UpdateProgress(++scannedBlocks, totalBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user