Skip to content

eval: reduce redundant work during evaluation runs#2047

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/docke-agent-eval-can-take-a-long-time-ar-10a5596e
Mar 10, 2026
Merged

eval: reduce redundant work during evaluation runs#2047
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/docke-agent-eval-can-take-a-long-time-ar-10a5596e

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Mar 10, 2026

Summary

Reduce redundant work during docker agent eval runs to improve performance without changing behavior.

Changes

  • Deduplicate concurrent Docker image builds using singleflight so 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.Once to avoid permanently caching transient errors (e.g. context cancellation).

  • Compute getUserMessages once per eval instead of calling it three times with the same session in runSingleEval.

- 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
@dgageot dgageot requested a review from a team as a code owner March 10, 2026 18:09
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@dgageot dgageot merged commit d9f5036 into docker:main Mar 10, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants