Skip to content

Commit 18244a2

Browse files
committed
test: add data-path benchmarks and S3 request-count assertions
1 parent 192569f commit 18244a2

7 files changed

Lines changed: 623 additions & 3 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ lifecycle rule. It cleans up multipart uploads left incomplete if the server
122122
exits during composition; verify lifecycle support when using an S3-compatible
123123
endpoint.
124124

125+
An AWS S3 lifecycle configuration can scope the rule to the cache prefix:
126+
127+
```json
128+
{
129+
"Rules": [
130+
{
131+
"ID": "abort-incomplete-cache-uploads",
132+
"Status": "Enabled",
133+
"Filter": { "Prefix": "gh-actions-cache/" },
134+
"AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 1 }
135+
}
136+
]
137+
}
138+
```
139+
125140
### Cache Behavior
126141

127142
| Variable | Default | Description |
@@ -201,6 +216,21 @@ E2E_S3_BUCKET=cache-test \
201216
go test ./e2e -run 'TestExternal(Postgres|MySQL|S3MinIO)SaveAndRestore' -count=1
202217
```
203218

219+
Targeted data-path benchmarks cover filesystem whole-cache upload/download,
220+
Azure block commit, ordered-parts versus merged downloads, concurrent runners,
221+
and S3 server-side composition:
222+
223+
```sh
224+
go test ./internal/cache ./internal/storage -run '^$' -bench 'Benchmark(Filesystem|Azure|S3)' -benchmem -count=5
225+
```
226+
227+
Streaming benchmarks run with 32 KiB, 128 KiB, 256 KiB, and 1 MiB buffers.
228+
The concurrent-runner benchmark also reports p95 latency and peak process RSS;
229+
the deterministic S3 protocol benchmark reports and asserts SDK HTTP requests
230+
per composition. When `E2E_S3_ENDPOINT_URL` and `E2E_S3_BUCKET` are configured,
231+
the same command also runs composition against that external S3-compatible
232+
backend to measure its wall-clock latency.
233+
204234
The repository also contains a Go smoke test for the cache v2 HTTP protocol
205235
shape. Full runner-level compatibility should be tested with the patched
206236
falcondev runner container and a real GitHub Actions job.

internal/cache/rss_linux_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//go:build linux
2+
3+
package cache
4+
5+
import (
6+
"os"
7+
"strconv"
8+
"strings"
9+
)
10+
11+
func processRSSBytes() uint64 {
12+
contents, err := os.ReadFile("/proc/self/statm")
13+
if err != nil {
14+
return 0
15+
}
16+
fields := strings.Fields(string(contents))
17+
if len(fields) < 2 {
18+
return 0
19+
}
20+
residentPages, err := strconv.ParseUint(fields[1], 10, 64)
21+
if err != nil {
22+
return 0
23+
}
24+
return residentPages * uint64(os.Getpagesize())
25+
}

internal/cache/rss_other_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build !windows && !linux
2+
3+
package cache
4+
5+
func processRSSBytes() uint64 {
6+
return 0
7+
}

internal/cache/rss_windows_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//go:build windows
2+
3+
package cache
4+
5+
import (
6+
"syscall"
7+
"unsafe"
8+
)
9+
10+
var getProcessMemoryInfo = syscall.NewLazyDLL("psapi.dll").NewProc("GetProcessMemoryInfo")
11+
12+
type processMemoryCounters struct {
13+
Size uint32
14+
PageFaultCount uint32
15+
PeakWorkingSetSize uintptr
16+
WorkingSetSize uintptr
17+
QuotaPeakPagedPoolUsage uintptr
18+
QuotaPagedPoolUsage uintptr
19+
QuotaPeakNonPagedPoolUsage uintptr
20+
QuotaNonPagedPoolUsage uintptr
21+
PagefileUsage uintptr
22+
PeakPagefileUsage uintptr
23+
}
24+
25+
func processRSSBytes() uint64 {
26+
handle, err := syscall.GetCurrentProcess()
27+
if err != nil {
28+
return 0
29+
}
30+
counters := processMemoryCounters{Size: uint32(unsafe.Sizeof(processMemoryCounters{}))}
31+
result, _, _ := getProcessMemoryInfo.Call(
32+
uintptr(handle),
33+
uintptr(unsafe.Pointer(&counters)),
34+
uintptr(counters.Size),
35+
)
36+
if result == 0 {
37+
return 0
38+
}
39+
return uint64(counters.WorkingSetSize)
40+
}

0 commit comments

Comments
 (0)