Skip to content

Add a MultiGet API to reduce lock contention#145

Merged
coocood merged 2 commits intocoocood:masterfrom
liusy182:multi-get
Mar 19, 2026
Merged

Add a MultiGet API to reduce lock contention#145
coocood merged 2 commits intocoocood:masterfrom
liusy182:multi-get

Conversation

@liusy182
Copy link
Copy Markdown
Contributor

@liusy182 liusy182 commented Mar 19, 2026

Add a MultiGet API to reduce lock contention during high parallelism.

Sample benchmark result:

> go test -bench='Benchmark.*Batched'
BenchmarkParallelCacheGetBatched-16         	  181435	      6771 ns/op	    1538 B/op	      24 allocs/op
BenchmarkParallelCacheMultiGetBatched-16    	  523794	      2289 ns/op	   12806 B/op	     201 allocs/op
PASS
ok  	github.com/coocood/freecache	35.086s

@coocood
Copy link
Copy Markdown
Owner

coocood commented Mar 19, 2026

For other concurrent single key get operation, the tail latency would be much higher.

@liusy182
Copy link
Copy Markdown
Contributor Author

For other concurrent single key get operation, the tail latency would be much higher.

Thank you for the input! Yes, I agree.
In the use case I work on, we perform large batches of Get() uniformly and it is highly concurrent. Because of that, I still see MultiGet might have value depending on the workload - e.g. when not mixing with singular Get().

@coocood
Copy link
Copy Markdown
Owner

coocood commented Mar 19, 2026

OK, then we better update the API comment to add a note for the tail latency cost.

@coocood coocood merged commit 1442997 into coocood:master Mar 19, 2026
9 of 10 checks passed
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.

2 participants