pg.ddx.io pgvector/pgvector GitHub issues and pull requestshelp / color / mirror / Atom feed
[pgvector/pgvector] issue #692: Memory context leak in vacuum? 3+ messages / 2 participants [nested] [flat]
* [pgvector/pgvector] issue #692: Memory context leak in vacuum? @ 2024-10-08 19:15 "MMeent (@MMeent)" <noreply+MMeent@github.com> 0 siblings, 0 replies; 3+ messages in thread From: MMeent (@MMeent) @ 2024-10-08 19:15 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> As I looked through the recent changes, I noticed the following curiosity: In the recent commit (unreleased) 57248ba1, a new memory context is allocated in every call to HnswUpdateNeighborsOnDisk. That function, in turn, is called ~unconditionally from RepairGraphElement in [hnswvacuum](https://github.com/pgvector/pgvector/blob/master/src/hnswvacuum.c#L184), which in turn is called repeatedly from various points during vacuum. It seems to me that this leaks one 128kB generation memory context for every call. While the context is reset at the end of the underlying function, it doesn't get destroyed at the end of HnswUpdateNeighborsOnDisk, and thus the first memory chunk of 128kB is never released; which may lead to OOMs in memory-constrained environments when vacuuming large graphs that have many deletions. Note that this leak does not outlive its parent's lifetime, but if we assume that that context is the vacuum operation's context then that context may live for a long time, so it'd be preferred if the generation context was reused and not leaked. ^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #692: Memory context leak in vacuum? @ 2024-10-08 19:21 ` "ankane (@ankane)" <noreply+ankane@github.com> 1 sibling, 0 replies; 3+ messages in thread From: ankane (@ankane) @ 2024-10-08 19:21 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> @ankane closed this. ^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #692: Memory context leak in vacuum? @ 2024-10-08 19:25 ` "ankane (@ankane)" <noreply+ankane@github.com> 1 sibling, 0 replies; 3+ messages in thread From: ankane (@ankane) @ 2024-10-08 19:25 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Thanks @MMeent, great catch! Meant to keep the context contained in `HnswUpdateNeighborsOnDisk`. Edit: I'm not sure this would have been an issue due to the `tmpCtxt` in `RepairGraph`, but it's good to correct anyways. ^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-10-08 19:25 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-10-08 19:15 [pgvector/pgvector] issue #692: Memory context leak in vacuum? "MMeent (@MMeent)" <noreply+MMeent@github.com> 2024-10-08 19:21 ` "ankane (@ankane)" <noreply+ankane@github.com> 2024-10-08 19:25 ` "ankane (@ankane)" <noreply+ankane@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