Allow -1 (unbounded) parallelism; validate settings#3110
Merged
JimBobSquarePants merged 1 commit intomainfrom Apr 9, 2026
Merged
Allow -1 (unbounded) parallelism; validate settings#3110JimBobSquarePants merged 1 commit intomainfrom
JimBobSquarePants merged 1 commit intomainfrom
Conversation
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.
Prerequisites
Description
This pull request enhances the flexibility and robustness of parallel execution in ImageSharp by allowing an unbounded degree of parallelism (using
-1), improving validation for parallel execution settings, and updating the parallel row iteration logic accordingly. It also adds comprehensive tests to ensure the new behaviors are correct and validated.Parallel execution improvements:
ParallelExecutionSettingsto document and support-1as an unbounded value forMaxDegreeOfParallelism, and clarified this in both the code and XML documentation. [1] [2] [3] [4]ParallelRowIteratorto support unbounded parallelism: introducedGetNumberOfStepsandCreateParallelOptionshelpers, and adjusted how the number of steps and parallel options are calculated whenMaxDegreeOfParallelismis-1. [1] [2] [3] [4] [5] [6] [7] [8] [9]Validation and safety enhancements:
ValidateSettingsto ensureParallelExecutionSettingsare valid (e.g.,MaxDegreeOfParallelismnot zero or less than-1,MinimumPixelsProcessedPerTask> 0, andMemoryAllocatornot null), guarding against invalid struct defaults and improving error messages.Testing improvements:
MaxDegreeOfParallelism = -1results in all rows being processed, and that default (uninitialized)ParallelExecutionSettingsthrow appropriate exceptions. Introduced helper types for test operations. [1] [2] [3] [4]