Skip to content

chore: Do not use PLINQ to create the ignore patterns - #1797

Merged
HofmeisterAn merged 3 commits into
developfrom
fix/build-context-without-plinq
Oct 14, 2026
Merged

HofmeisterAn merged 3 commits into
developfrom
fix/build-context-without-plinq

Conversation

@HofmeisterAn

@HofmeisterAn HofmeisterAn commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

This PR removes PLINQ from creating the Docker build context. IgnoreFile.Accepts now checks the patterns in a loop from the last to the first and stops at the first match, so the last matching pattern still decides whether a file is accepted. IgnoreFile creates the ignore patterns with LINQ instead of AsParallel().AsOrdered(), and DockerfileArchive collects the build context files without AsParallel().

Why is it important?

Accepts runs for every file in the build context, and each call started a PLINQ query over a few regular expressions. The query setup costs more than the matching itself. For a context with ~5,200 files, checking all files takes 35 ms instead of 96 ms and allocates ~33 MB less. PLINQ also blocks the calling thread until the thread pool runs its work, so when the thread pool is busy, e.g. in large test suites, creating the build context can stall for several seconds. Without AsOrdered(), the files were also added to the tar archive in a different order on every run. The order is stable now.

Related issues

-

Summary by CodeRabbit

  • Bug Fixes
    • Ignore rules now consistently honor the last matching rule, with files included when no rule matches.
    • File paths are processed sequentially when reading Docker build archives.

@HofmeisterAn HofmeisterAn added the chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups label Oct 14, 2026
@netlify

netlify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 2a0e0d5
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/6acf22513eaeab313b56130a
😎 Deploy Preview https://deploy-preview-1797--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0614ebeb-ccdf-4fec-b179-58f44cfb0256
📥 Commits

Reviewing files that changed from the base of the PR and between bdf5175 and 2a0e0d5.

📒 Files selected for processing: 2
  • src/Testcontainers/Images/DockerfileArchive.cs
  • src/Testcontainers/Images/IgnoreFile.cs
💤 Files with no reviewable changes: 1
  • src/Testcontainers/Images/DockerfileArchive.cs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

File enumeration and ignore-pattern processing no longer use parallel queries. IgnoreFile stores patterns in an array and checks them from last to first.

Changes

Image processing

Layer / File(s) Summary
Sequential file and pattern processing
src/Testcontainers/Images/IgnoreFile.cs, src/Testcontainers/Images/DockerfileArchive.cs
IgnoreFile stores patterns in an array and checks them in reverse order, returning the value of the last matching pattern. DockerfileArchive.GetFiles processes file paths sequentially.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 2a0e0

Ignore rules retain their source order and apply the last matching rule deterministically, while archive file enumeration is sequential. No concrete user-facing or operational regression is evident, so the change is ready for normal merge checks.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description explains what changed and why it matters. It covers the removal of PLINQ from ignore-pattern creation and build-context collection, the reverse matching logic, performance results, all…
Title check Passed The title clearly describes a real part of the change: removing PLINQ from ignore-pattern creation. It does not mention the related Docker build-context enumeration change, but it remains specific and…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each path in line,
Then scans the patterns, last to first.
The archive files pass one by one,
No parallel paths to cross or run.
It hops away, its work now done.

Comment @coderabbitai help to get the list of available commands.

@HofmeisterAn
HofmeisterAn merged commit 6f551c9 into develop Oct 14, 2026
83 checks passed
@HofmeisterAn
HofmeisterAn deleted the fix/build-context-without-plinq branch October 14, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore A change that doesn't impact the existing functionality, e.g. internal refactorings or cleanups

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant