Repository navigation
Steer only what the strategy can act on, and stop paying generic netlink costs #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f492f1e
Steer only what the strategy can act on
reflog 09b3de3
bench: stop tracking the strategy mount target
reflog 531d50f
Own the netlink hot path instead of paying for a generic one
reflog 68097a6
Document what --observe-inbound actually costs
reflog 74d0455
Refuse --observe-inbound in prod mode
reflog b7167f5
Address Copilot review: set the netlink family, document the verdict …
reflog 753a962
Address CodeRabbit review: a shutdown hang, a stale table, and honest…
reflog ee02c81
Bump geneva for the per-packet allocation fixes
reflog e53774d
Count the censor signal in the kernel instead of steering for it
reflog 476e057
Apply the cleanup review: dedup helpers, unblock the censor read, tri…
reflog df53c2d
Address Copilot review: parenthesize flag sets, classify apply errors…
reflog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Benchmark-only image: the bulk load generator plus the tooling the runner uses | ||
| # to drive the control API and read the sidecar's counters. | ||
| FROM golang:1.25-bookworm AS builder | ||
| WORKDIR /src | ||
| COPY go.mod go.sum ./ | ||
| RUN go mod download | ||
| COPY . . | ||
| RUN CGO_ENABLED=0 go build -trimpath -o /out/bulk ./bench/bulk | ||
|
|
||
| FROM debian:bookworm-slim | ||
| RUN set -ex \ | ||
| && apt-get update \ | ||
| && apt-get install -y --no-install-recommends curl jq ethtool ca-certificates \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| COPY --from=builder /out/bulk /usr/local/bin/bulk | ||
| ENTRYPOINT ["/usr/local/bin/bulk"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| // Command bulk is the load generator for the sidecar benchmark. It is both the | ||
| // server and the client so that a single image covers both ends, and it streams | ||
| // from a reused buffer rather than materializing the payload: the benchmark | ||
| // moves gigabytes, and a payload held in memory would measure the allocator. | ||
| // | ||
| // It deliberately speaks plain HTTP. The sidecar only ever manipulates outer | ||
| // IPv4/TCP headers, so wrapping the stream in TLS would add proxy-side crypto | ||
| // cost to every number without changing a single packet the sidecar sees. | ||
| package main | ||
|
|
||
| import ( | ||
| "crypto/rand" | ||
| "flag" | ||
| "fmt" | ||
| "io" | ||
| "log" | ||
| "net/http" | ||
| "os" | ||
| "strconv" | ||
| "sync" | ||
| "time" | ||
| ) | ||
|
|
||
| const chunkSize = 256 << 10 | ||
|
|
||
| func main() { | ||
| serve := flag.String("serve", "", "serve bulk data on this address (e.g. :8080)") | ||
| get := flag.String("get", "", "fetch bulk data from this base URL (e.g. http://server:8080)") | ||
| bytes := flag.Int64("bytes", 2<<30, "bytes to transfer per stream") | ||
| streams := flag.Int("streams", 1, "concurrent streams") | ||
| flag.Parse() | ||
|
|
||
| switch { | ||
| case *serve != "": | ||
| runServer(*serve) | ||
| case *get != "": | ||
| if err := runClient(*get, *bytes, *streams); err != nil { | ||
| // Exit non-zero rather than printing a throughput figure: a | ||
| // half-finished transfer that reports a number is how a broken | ||
| // condition gets recorded as a benchmark result. | ||
| log.Fatal(err) | ||
| } | ||
| default: | ||
| log.Fatal("one of -serve or -get is required") | ||
| } | ||
| } | ||
|
|
||
| func runServer(addr string) { | ||
| // Random rather than zeros: a NIC or a virtual link that compresses or | ||
| // dedupes would otherwise flatter the benchmark. | ||
| chunk := make([]byte, chunkSize) | ||
| if _, err := rand.Read(chunk); err != nil { | ||
| log.Fatal(err) | ||
| } | ||
|
|
||
| mux := http.NewServeMux() | ||
| mux.HandleFunc("/bulk", func(w http.ResponseWriter, r *http.Request) { | ||
| n, err := strconv.ParseInt(r.URL.Query().Get("bytes"), 10, 64) | ||
| if err != nil || n < 0 { | ||
| http.Error(w, "bad bytes", http.StatusBadRequest) | ||
| return | ||
| } | ||
| w.Header().Set("Content-Type", "application/octet-stream") | ||
| w.Header().Set("Content-Length", strconv.FormatInt(n, 10)) | ||
| for n > 0 { | ||
| c := int64(len(chunk)) | ||
| if n < c { | ||
| c = n | ||
| } | ||
| if _, err := w.Write(chunk[:c]); err != nil { | ||
| return | ||
| } | ||
| n -= c | ||
| } | ||
| }) | ||
| mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { | ||
| _, _ = w.Write([]byte("ok")) | ||
| }) | ||
|
|
||
| log.Printf("bulk server listening on %s", addr) | ||
| srv := &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: 5 * time.Second} | ||
| log.Fatal(srv.ListenAndServe()) | ||
| } | ||
|
|
||
| // runClient reports MB/s on stdout as a bare number, so the runner can read it | ||
| // without parsing prose. Any stream that fails, returns a non-200, or comes up | ||
| // short is an error: the number would be meaningless and the runner cannot tell | ||
| // a slow condition from a broken one. | ||
| func runClient(base string, n int64, streams int) error { | ||
| client := &http.Client{Timeout: 30 * time.Minute} | ||
| url := fmt.Sprintf("%s/bulk?bytes=%d", base, n) | ||
|
|
||
| var wg sync.WaitGroup | ||
| got := make([]int64, streams) | ||
| errs := make([]error, streams) | ||
| start := time.Now() | ||
| for i := range streams { | ||
| wg.Add(1) | ||
| go func(i int) { | ||
| defer wg.Done() | ||
| resp, err := client.Get(url) | ||
| if err != nil { | ||
| errs[i] = fmt.Errorf("stream %d: %w", i, err) | ||
| return | ||
| } | ||
| defer func() { _ = resp.Body.Close() }() | ||
| if resp.StatusCode != http.StatusOK { | ||
| errs[i] = fmt.Errorf("stream %d: HTTP %d", i, resp.StatusCode) | ||
| return | ||
| } | ||
| c, err := io.Copy(io.Discard, resp.Body) | ||
| got[i] = c | ||
| if err != nil { | ||
| errs[i] = fmt.Errorf("stream %d: after %d bytes: %w", i, c, err) | ||
| } | ||
| }(i) | ||
| } | ||
| wg.Wait() | ||
| elapsed := time.Since(start) | ||
|
|
||
| for _, err := range errs { | ||
| if err != nil { | ||
| return err | ||
| } | ||
| } | ||
| var total int64 | ||
| for _, c := range got { | ||
| total += c | ||
| } | ||
| if want := n * int64(streams); total != want { | ||
| return fmt.Errorf("short transfer: got %d of %d bytes", total, want) | ||
| } | ||
| mbps := float64(total) / (1 << 20) / elapsed.Seconds() | ||
| _, _ = fmt.Fprintf(os.Stdout, "%.2f\n", mbps) | ||
| return nil | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Benchmark topology. Mirrors e2e/docker-compose.yml, with the echo server | ||
| # replaced by a streaming bulk server and the sidecar's arguments driven from | ||
| # the environment so the runner can sweep modes without editing this file. | ||
| # | ||
| # server — the "proxy": bulk data on :8080, and owner of the network namespace | ||
| # sidecar — geneva-server sharing the server's netns, steering :8080 | ||
| # client — pulls bulk data across the bridge; the load generator | ||
| # probe — on-demand container in the server's netns for nft/ethtool state | ||
| name: geneva-bench | ||
|
|
||
| services: | ||
| server: | ||
| build: | ||
| context: .. | ||
| dockerfile: bench/Dockerfile.bulk | ||
| image: geneva-bench/bulk:latest | ||
| command: ["-serve", ":8080"] | ||
| healthcheck: | ||
| test: ["CMD", "curl", "-fsS", "http://localhost:8080/healthz"] | ||
| interval: "1s" | ||
| timeout: "2s" | ||
| retries: 30 | ||
|
|
||
| sidecar: | ||
| build: | ||
| context: .. | ||
| dockerfile: Dockerfile | ||
| image: geneva-bench/sidecar:latest | ||
| network_mode: "service:server" | ||
| cap_add: | ||
| - NET_ADMIN | ||
| - NET_RAW | ||
| depends_on: | ||
| server: | ||
| condition: service_healthy | ||
| volumes: | ||
| - ./strategy.dna:/strategy.dna:ro | ||
| command: | ||
| - "run" | ||
| - "--mode=${GENEVA_MODE:-eval}" | ||
| - "--market=RU" | ||
| - "--port=8080" | ||
| - "--iface=eth0" | ||
| - "--control-addr=0.0.0.0:8092" | ||
| # Always a file, never a flag toggle: the runner rewrites strategy.dna | ||
| # between conditions, and an empty file is exactly the pass-through case. | ||
| - "--strategy-file=/strategy.dna" | ||
| # Debug-only, and only ever in this harness: the profile is what tells us | ||
| # whether a cost is in the engine or in the plumbing around it. | ||
| - "--pprof-addr=0.0.0.0:6060" | ||
|
|
||
| client: | ||
| image: geneva-bench/bulk:latest | ||
| depends_on: | ||
| server: | ||
| condition: service_healthy | ||
| profiles: ["tools"] | ||
| entrypoint: ["sleep", "infinity"] | ||
|
|
||
| probe: | ||
| image: geneva-bench/sidecar:latest | ||
| network_mode: "service:server" | ||
| profiles: ["tools"] | ||
| entrypoint: ["sleep", "infinity"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.