mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-11 07:06:57 +08:00
Reverted FlushPages pattern for parallel builds
This commit is contained in:
@@ -432,18 +432,15 @@ BuildCallback(Relation index, CALLBACK_ITEM_POINTER, Datum *values,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* Flush pages if needed */
|
/* Flush pages if needed */
|
||||||
HnswLockAcquire(hnswshared);
|
|
||||||
if (!graph->flushed && graph->memoryUsed >= graph->memoryTotal)
|
if (!graph->flushed && graph->memoryUsed >= graph->memoryTotal)
|
||||||
{
|
{
|
||||||
if (!hnswshared)
|
ereport(NOTICE,
|
||||||
ereport(NOTICE,
|
(errmsg("hnsw graph no longer fits into maintenance_work_mem after " INT64_FORMAT " tuples", (int64) graph->indtuples),
|
||||||
(errmsg("hnsw graph no longer fits into maintenance_work_mem after " INT64_FORMAT " tuples", (int64) graph->indtuples),
|
errdetail("Building will take significantly more time."),
|
||||||
errdetail("Building will take significantly more time."),
|
errhint("Increase maintenance_work_mem to speed up builds.")));
|
||||||
errhint("Increase maintenance_work_mem to speed up builds.")));
|
|
||||||
|
|
||||||
FlushPages(buildstate);
|
FlushPages(buildstate);
|
||||||
}
|
}
|
||||||
HnswLockRelease(hnswshared);
|
|
||||||
|
|
||||||
oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx);
|
oldCtx = MemoryContextSwitchTo(buildstate->tmpCtx);
|
||||||
|
|
||||||
@@ -825,6 +822,7 @@ HnswBeginParallel(HnswBuildState * buildstate, bool isconcurrent, int request)
|
|||||||
InitGraph(&hnswshared->graphData);
|
InitGraph(&hnswshared->graphData);
|
||||||
/* TODO Support in-memory builds */
|
/* TODO Support in-memory builds */
|
||||||
hnswshared->graphData.memoryTotal = 0;
|
hnswshared->graphData.memoryTotal = 0;
|
||||||
|
hnswshared->graphData.flushed = true;
|
||||||
#if PG_VERSION_NUM >= 120000
|
#if PG_VERSION_NUM >= 120000
|
||||||
table_parallelscan_initialize(buildstate->heap,
|
table_parallelscan_initialize(buildstate->heap,
|
||||||
ParallelTableScanFromHnswShared(hnswshared),
|
ParallelTableScanFromHnswShared(hnswshared),
|
||||||
@@ -912,7 +910,11 @@ BuildGraph(HnswBuildState * buildstate, ForkNumber forkNum)
|
|||||||
|
|
||||||
/* Attempt to launch parallel worker scan when required */
|
/* Attempt to launch parallel worker scan when required */
|
||||||
if (parallel_workers > 0)
|
if (parallel_workers > 0)
|
||||||
|
{
|
||||||
|
/* TODO Support in-memory builds */
|
||||||
|
FlushPages(buildstate);
|
||||||
HnswBeginParallel(buildstate, buildstate->indexInfo->ii_Concurrent, parallel_workers);
|
HnswBeginParallel(buildstate, buildstate->indexInfo->ii_Concurrent, parallel_workers);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add tuples to graph */
|
/* Add tuples to graph */
|
||||||
if (buildstate->heap != NULL)
|
if (buildstate->heap != NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user