Skip to content

Conversation

@tomhjp
Copy link
Collaborator

@tomhjp tomhjp commented Oct 16, 2025

This is the script I've been using locally to reproducibly simulate what kind of speed-ups I can expect to see for a specific go project depending on how close gocached is and how many cache hits we get. I also experimented with a -miss-percentage flag on go-cacher, but the results were roughly what you'd expect interpolating between cold and warm benchmarks.

Typical output for running with defaults:

$ ./scripts/benchmark.sh 
---- LATENCY=0 ----

Testing with cold cache...
2025/10/16 12:53:36 go-cacher: verbose mode enabled
2025/10/16 12:53:45 cacher: closing; 494 gets (0 hits, 494 misses, 0 errors); 1026 puts (0 errors)
Cold run took 8762ms

Testing with warm HTTP and disk cache...
2025/10/16 12:53:46 go-cacher: verbose mode enabled
2025/10/16 12:53:46 cacher: closing; 747 gets (744 hits, 3 misses, 0 errors); 3 puts (0 errors)
Warm run took 497ms

Testing with warm HTTP cache only...
2025/10/16 12:53:47 go-cacher: verbose mode enabled
2025/10/16 12:53:48 cacher: closing; 747 gets (744 hits, 3 misses, 0 errors); 3 puts (0 errors)
HTTP run took 628ms

@tomhjp tomhjp requested review from bradfitz and irbekrm October 16, 2025 11:39
This is the script I've been using locally to reproducibly simulate what
kind of speed-ups I can expect to see for a specific go project
depending on how close gocached is and how many cache hits we get. I
also experimented with a -miss-percentage flag on go-cacher, but the
results were roughly what you'd expect interpolating between cold and
warm benchmarks.

Typical output for running with defaults:

```shell-session
$ ./scripts/benchmark.sh
---- LATENCY=0 ----

Testing with cold cache...
2025/10/16 12:53:36 go-cacher: verbose mode enabled
2025/10/16 12:53:45 cacher: closing; 494 gets (0 hits, 494 misses, 0 errors); 1026 puts (0 errors)
Cold run took 8762ms

Testing with warm HTTP and disk cache...
2025/10/16 12:53:46 go-cacher: verbose mode enabled
2025/10/16 12:53:46 cacher: closing; 747 gets (744 hits, 3 misses, 0 errors); 3 puts (0 errors)
Warm run took 497ms

Testing with warm HTTP cache only...
2025/10/16 12:53:47 go-cacher: verbose mode enabled
2025/10/16 12:53:48 cacher: closing; 747 gets (744 hits, 3 misses, 0 errors); 3 puts (0 errors)
HTTP run took 628ms
```

Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
tomhjp added a commit that referenced this pull request Oct 16, 2025
Running with a cold disk cache for go-cacher and a warm disk cache for
go-cacher-server, I was getting no cache hits. This is due to a missing
component in the output filename when serving up what go-cacher-server
thinks is a cache hit; it was trying to serve from <dir>/o-<hex> instead
of the real file location of <dir>/<o2>/o-<hex> where o2 is the first 2
characters of the hex string.

To help with consistency, I consolidated all places that need to
calculate an action or output file path into 2 shared functions, but
there is only one functional change. Tested via the benchmarks I
included in #17, but it's probably worth investing in some unit tests as
well as we start to use this more seriously.

Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
tomhjp added a commit that referenced this pull request Oct 16, 2025
Running with a cold disk cache for go-cacher and a warm disk cache for
go-cacher-server, I was getting no cache hits. This is due to a missing
component in the output filename when serving up what go-cacher-server
thinks is a cache hit; it was trying to serve from `<dir>/o-<hex>` instead
of the real file location of `<dir>/<o2>/o-<hex>` where o2 is the first 2
characters of the hex string.

To help with consistency, I consolidated all places that need to
calculate an action or output file path into 2 shared functions, but
there is only one functional change. Tested via the benchmarks I
included in #17, but it's probably worth investing in some unit tests as
well as we start to use this more seriously.

Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
tomhjp added a commit that referenced this pull request Oct 17, 2025
Running with a cold disk cache for go-cacher and a warm disk cache for
go-cacher-server, I was getting no cache hits. This is due to a missing
component in the output filename when serving up what go-cacher-server
thinks is a cache hit; it was trying to serve from `<dir>/o-<hex>` instead
of the real file location of `<dir>/<o2>/o-<hex>` where o2 is the first 2
characters of the hex string.

To help with consistency, I consolidated all places that need to
calculate an action or output file path into 2 shared functions, but
there is only one functional change. Tested via the benchmarks I
included in #17, but it's probably worth investing in some unit tests as
well as we start to use this more seriously.

Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
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