perf: add processor hot-path benchmarks#160
Merged
Merged
Conversation
The SDK had zero benchmarks despite reference resolution and Process being on the per-record hot path for every processor. Adds: - internal/reference: BenchmarkNewResolver (one-time parse cost), BenchmarkResolver_Resolve, and BenchmarkResolver_ResolveAndSet (per-record resolve/get/set cost), covering raw and structured payloads, top-level and nested structured fields, and bracket-index metadata keys. - BenchmarkProcessorFunc_Process_MetadataFieldSet and BenchmarkProcessorFunc_Process_StructuredFieldSet: a representative field-set processor built on ProcessorFunc (the SDK's only concrete, reusable Processor implementation), exercising a full batch Process call end to end. These establish a baseline for catching per-record regressions; no production code changed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tapg9dLWXKMZJoL65R24vd
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This repo had zero benchmarks despite
Processor.Processand referenceresolution (
internal/reference) sitting on the per-record hot path forevery processor invocation. Adds committed benchmarks so future changes
to these paths have a baseline to regress against.
internal/reference/reference_bench_test.go:BenchmarkNewResolver- one-time reference-string parse/validate cost(paid once, typically at
Configure).BenchmarkResolver_Resolve- per-record resolve +Get(), coveringraw vs. structured payloads, top-level fields (
.Key,.Payload.After), metadata fields (plain and bracket-indexed), andstructured sub-fields (including nested).
BenchmarkResolver_ResolveAndSet- per-record resolve +Set(),the pattern used by field-set/rename-style processors.
processor_func_bench_test.go:BenchmarkProcessorFunc_Process_MetadataFieldSetandBenchmarkProcessorFunc_Process_StructuredFieldSet- arepresentative field-set processor built on
ProcessorFunc(theSDK's only concrete, reusable
Processorimplementation), exercisinga full 100-record batch
Processcall end to end.The SDK itself ships no concrete field-set/rename processor (those live
in the main
conduitrepo), so theProcess-level benchmark usesProcessorFuncwired to the same resolve-then-set pattern realprocessors use — the closest thing to "a representative processor" that
this repo actually exposes.
No production code changed.
Numbers (Apple M3 Max,
go test -bench . -benchmem -benchtime 2s ./...)Reference resolution (per record, after
NewResolveris done once):.Key(raw).Key(structured).Metadata.field(raw).Metadata.field(structured).Payload.After(raw).Payload.After(structured).Payload.After.status(structured).Payload.After.customer.name(structured, nested).Metadata.field(raw).Metadata.field(structured).Payload.After.status(structured).Payload.After.customer.name(structured, nested)NewResolver(paid once per reference string, not per record): 210 ns –720 ns, 3–11 allocs, depending on reference depth.
ProcessorFunc.Processon a 100-record batch:Test plan
go build ./...go test ./... -count=1go test ./... -count=1 -racegolangci-lint run ./...- 0 issuesGOOS=wasip1 GOARCH=wasm go build ./...- WASM build unaffectedgo test -bench . -benchmem -benchtime 2s ./...- all benchmarks pass, numbers above🤖 Generated with Claude Code
https://claude.ai/code/session_01Tapg9dLWXKMZJoL65R24vd