Currently processImage does file I/O, decode, and encode sequentially in one function inside a single worker goroutine. Separating into 3 pipeline stages allows each stage to run concurrently and makes bottleneck identification precise.
Scope:
internal/pipeline/reader.go — file open and raw bytes read, outputs to decode channel
internal/pipeline/decoder.go — JPEG/PNG decode from raw bytes, outputs image.Image to encode channel
internal/pipeline/encoder.go — WebP encode and file write, outputs Result
- Each stage has its own bounded channel and worker count
- Add stage-level metrics: time spent in read vs decode vs encode separately
Architecture:
JobsChan → [Reader goroutines] → rawChan → [Decoder goroutines] → imgChan → [Encoder goroutines] → ResultsChan
Acceptance Criteria:
- Each stage independently configurable in worker count
- Stage timing visible in
summary.json under stage_metrics
- Memory profile shows decode buffer reuse across pipeline
- All existing tests pass against new architecture
BENCHMARKS.md updated with stage-level timing breakdown
Currently
processImagedoes file I/O, decode, and encode sequentially in one function inside a single worker goroutine. Separating into 3 pipeline stages allows each stage to run concurrently and makes bottleneck identification precise.Scope:
internal/pipeline/reader.go— file open and raw bytes read, outputs to decode channelinternal/pipeline/decoder.go— JPEG/PNG decode from raw bytes, outputsimage.Imageto encode channelinternal/pipeline/encoder.go— WebP encode and file write, outputs ResultArchitecture:
Acceptance Criteria:
summary.jsonunderstage_metricsBENCHMARKS.mdupdated with stage-level timing breakdown