Avoid loading compose info unless needed #1001
Closed
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.
This improves performance in scenarios where the caller does not rely or need compose in any way.
Anecdotal evidence is from a repository that has 289 test cases, ~260 of which somehow interact with testcontainers. There's enough abstraction between the tests and testcontainers so that not each of the tests hits this slow path, but still, the timing (run on a M3 Pro) shows a clear improvement.
Before - 19.69s, 18.30s, 18.05s, 17.54s, 17.70s - average 18.256s
After - 18.03s, 15.61s, 15.57s, 16.46s, 15.54s - average 16.242s
It's not much, but in all likelihood, depending on the setup, the difference is bigger with more parallel test suites, or situations in which
getContainerRuntimeClient
is called from different workers/processes more.