eval: reduce redundant work during evaluation runs#2047
Merged
dgageot merged 1 commit intodocker:mainfrom Mar 10, 2026
Merged
Conversation
- Deduplicate concurrent Docker image builds using singleflight so that parallel workers needing the same image only build it once. - Cache the structured-output judge provider across relevance checks instead of recreating it for every criterion. Use a mutex with retry-on-failure rather than sync.Once to avoid permanently caching transient errors (e.g. context cancellation). - Compute getUserMessages once per eval instead of three times. Assisted-By: docker-agent
There was a problem hiding this comment.
🟢 Code Review: APPROVE
Assessment
No bugs found in the changed code. The implementation correctly:
✅ Deduplicates concurrent Docker builds using singleflight.Group to prevent race conditions when multiple workers need the same image
✅ Caches the judge provider with proper mutex protection and retry-on-failure semantics (avoiding the sync.Once trap of permanently caching transient errors)
✅ Eliminates redundant getUserMessages calls by computing the value once and reusing it
All additions follow Go best practices:
- Proper synchronization patterns (mutex for cache, singleflight for deduplication)
- Type assertion with interface{} → string conversion for singleflight return value
- Cache write inside singleflight callback to guarantee availability before key release
- Retry-friendly error handling in judge provider creation
Performance Impact
These optimizations will meaningfully reduce evaluation time without changing behavior:
- Build deduplication: Prevents N parallel builds of the same image, reducing redundant Docker operations
- Provider caching: Eliminates repeated provider initialization overhead during relevance checks
- Message computation: Saves 2 redundant calls per evaluation
Automated review by cagent • No issues detected
aheritier
approved these changes
Mar 10, 2026
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
Reduce redundant work during docker agent eval runs to improve performance without changing behavior.
Changes
Deduplicate concurrent Docker image builds using
singleflightso that parallel workers needing the same image only build it once, instead of racing through the cache check and all starting separate builds.Cache the structured-output judge provider across relevance checks instead of recreating it for every criterion. Uses a mutex with retry-on-failure rather than
sync.Onceto avoid permanently caching transient errors (e.g. context cancellation).Compute
getUserMessagesonce per eval instead of calling it three times with the same session inrunSingleEval.