Skip to content

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

Merged
tvd12 merged 3 commits into
youngmonkeys:mainfrom
omninguyen:perf/hnsw-buffered-io
Sep 4, 2026
Merged

Use buffered streams for hnsw index save and load#1
tvd12 merged 3 commits into
youngmonkeys:mainfrom
omninguyen:perf/hnsw-buffered-io

Conversation

@omninguyen

@omninguyen omninguyen commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

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

Benchmark

save()

Nodes File size 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 size 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.

@omninguyen

Copy link
Copy Markdown
Contributor Author

@tvd12 Hi, can you review? Thanks.

@tvd12 tvd12 added the enhancement New feature or request label Sep 4, 2026
@tvd12

tvd12 commented Sep 4, 2026

Copy link
Copy Markdown
Member

@omninguyen đây là một cải tiến đáng giá, nhưng hãy để mình xem để buffer bao nhiêu thì phù hợp nhé

@tvd12 tvd12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tvd12 tvd12 added the good first issue Good for newcomers label Sep 4, 2026
@tvd12
tvd12 merged commit 3a058be into youngmonkeys:main Sep 4, 2026
@omninguyen
omninguyen deleted the perf/hnsw-buffered-io branch September 4, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants