Skip to content

Use buffered streams for hnsw index save and load - #1

Open
omninguyen wants to merge 1 commit into
youngmonkeys:mainfrom
omninguyen:perf/hnsw-buffered-io
Open

Use buffered streams for hnsw index save and load#1
omninguyen wants to merge 1 commit into
youngmonkeys:mainfrom
omninguyen:perf/hnsw-buffered-io

Conversation

@omninguyen

Copy link
Copy Markdown

Description

Wrap the save()/load() streams in BufferedOutputStream and BufferedInputStream.

Benchmark

save()

Nodes File Before After Speed-up
100 0.18 MB 18.9 ms 2.0 ms 9.5×
1,000 1.82 MB 180.0 ms 9.5 ms 19.0×
10,000 18.17 MB 1,469 ms 75 ms 19.6×
100,000 181.7 MB 16,595 ms 1,078 ms 15.4×
1,000,000 1.82 GB 200,931 ms 14,517 ms 13.8×

load()

Nodes File Before After Speed-up
100 0.18 MB 15.4 ms 1.7 ms 8.9×
1,000 1.82 MB 151.6 ms 9.9 ms 15.4×
10,000 18.17 MB 1,398 ms 93 ms 15.1×
100,000 181.7 MB 15,347 ms 1,658 ms 9.3×
1,000,000 1.82 GB 168,589 ms 19,795 ms 8.5×

Each node is an indexed vector; each file is the resulting hnsw.dat. Each row in benchmark uses dim = 384 with 32 neighbours per node. Environment: JDK 8, 4 vCPU, 15 GB RAM, Claude Code Cloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant