pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: michaelbautin (@michaelbautin) <noreply+michaelbautin@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #745: Automate estimation of amount of memory needed for fast HNSW index build
Date: Fri, 03 Jan 2025 01:18:04 +0000
Message-ID: <gh-pgvector-pgvector-745-c2568582537@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-745@github.com>
References: <gh-pgvector-pgvector-745@github.com>

Thanks! In #299, the function  being linked to is 
```c
/*
 * Get the max number of elements that fit into maintenance_work_mem
 */
static double
HnswGetMaxInMemoryElements(int m, double ml, int dimensions)
{
	Size		elementSize = sizeof(HnswElementData);
	double		avgLevel = -log(0.5) * ml;

	elementSize += sizeof(HnswNeighborArray) * (avgLevel + 1);
	elementSize += sizeof(HnswCandidate) * (m * (avgLevel + 2));
	elementSize += sizeof(ItemPointerData);
	elementSize += VECTOR_SIZE(dimensions);
	return (maintenance_work_mem * 1024L) / elementSize;
}
```

I see that that function is not present in the current version (v0.8.0) and the actual amount of memory consumed is being used for deciding when to start spilling to disk instead. I think it would be good to have a reliable function, accessible to the user, that could be used to estimate whether a particular HNSW index build could be completed in memory.

view thread (9+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-745-c2568582537@github.com>
Permalink:  ../gh-pgvector-pgvector-745-c2568582537@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox