From: bantmen (@bantmen) <noreply+bantmen@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #661: IVFFLAT QPS too low
Date: Fri, 30 Aug 2024 00:31:36 +0000
Message-ID: <gh-pgvector-pgvector-661-c2319548235@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-661@github.com>
References: <gh-pgvector-pgvector-661@github.com>
I migrated the database from `r5.2xlarge` to `r6gd.2xlarge` and performance characteristics are identical:
- The query performance is entirely determined by how many blocks were a cache miss
- We have the same ratio of I/O duration to number of blocks that were read
This is telling me that the query was not dependent on the I/O throughput to begin with so there is no difference between using EBS backed storage and local NVME SSD. For the former, the network latency is sub-millisecond so even with burst of many small reads we would not see a difference as the overall I/O timing is on the order of several seconds.
To double check, I stripped my query to its barebones and confirmed that the QPS is identical.
``` SQL
SET ivfflat.probes = 15;
SELECT table_name.embedding <=> CAST('{vector}' AS vector(1200)) AS distance
FROM table_name ORDER BY distance
LIMIT 800;
```
My conclusion from all of that is the way I/O is done is seemingly very inefficient as even though I/O is the clear bottleneck, the I/O throughput is not nearly saturated. For both the r5 and r6gd, I am seeing 6-7 mbps read throughput.
I am not sure if this is a consequence of how the IVFFLAT index reads are implemented or something deeper with PostgresQL but it is looking pretty concerning as the summary of it all is "if you are using the IVFFLAT index and want good p99 latency, you need the data to fit in memory". This is unfortunately cost prohibitive for us so I'll have to scratch off IVFFLAT as being performant enough for our use cases unless I can justify spending more money. Let me know if I am misinterpreting anything and I am happy to share more details if that is useful.
I will follow up with the (2) experiment.