mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 00:26:55 +08:00
Fixed locking for parallel HNSW index builds - fixes #635
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
## 0.7.4 (unreleased)
|
## 0.7.4 (unreleased)
|
||||||
|
|
||||||
|
- Fixed locking for parallel HNSW index builds
|
||||||
- Fixed compilation error with GCC 14 on i386 when SSE2 is not enabled
|
- Fixed compilation error with GCC 14 on i386 when SSE2 is not enabled
|
||||||
|
|
||||||
## 0.7.3 (2024-07-22)
|
## 0.7.3 (2024-07-22)
|
||||||
|
|||||||
@@ -379,7 +379,13 @@ UpdateNeighborsInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswEleme
|
|||||||
for (int lc = e->level; lc >= 0; lc--)
|
for (int lc = e->level; lc >= 0; lc--)
|
||||||
{
|
{
|
||||||
int lm = HnswGetLayerM(m, lc);
|
int lm = HnswGetLayerM(m, lc);
|
||||||
HnswNeighborArray *neighbors = HnswGetNeighbors(base, e, lc);
|
Size neighborsSize = HNSW_NEIGHBOR_ARRAY_SIZE(lm);
|
||||||
|
HnswNeighborArray *neighbors = palloc(neighborsSize);
|
||||||
|
|
||||||
|
/* Copy neighbors to local memory */
|
||||||
|
LWLockAcquire(&e->lock, LW_SHARED);
|
||||||
|
memcpy(neighbors, HnswGetNeighbors(base, e, lc), neighborsSize);
|
||||||
|
LWLockRelease(&e->lock);
|
||||||
|
|
||||||
for (int i = 0; i < neighbors->length; i++)
|
for (int i = 0; i < neighbors->length; i++)
|
||||||
{
|
{
|
||||||
@@ -389,7 +395,6 @@ UpdateNeighborsInMemory(char *base, FmgrInfo *procinfo, Oid collation, HnswEleme
|
|||||||
/* Keep scan-build happy on Mac x86-64 */
|
/* Keep scan-build happy on Mac x86-64 */
|
||||||
Assert(neighborElement);
|
Assert(neighborElement);
|
||||||
|
|
||||||
/* Use element for lock instead of hc since hc can be replaced */
|
|
||||||
LWLockAcquire(&neighborElement->lock, LW_EXCLUSIVE);
|
LWLockAcquire(&neighborElement->lock, LW_EXCLUSIVE);
|
||||||
HnswUpdateConnection(base, e, hc, lm, lc, NULL, NULL, procinfo, collation);
|
HnswUpdateConnection(base, e, hc, lm, lc, NULL, NULL, procinfo, collation);
|
||||||
LWLockRelease(&neighborElement->lock);
|
LWLockRelease(&neighborElement->lock);
|
||||||
|
|||||||
Reference in New Issue
Block a user