Skip to content

Allow -1 (unbounded) parallelism; validate settings#3110

Merged
JimBobSquarePants merged 1 commit intomainfrom
js/parallel-settings
Apr 9, 2026
Merged

Allow -1 (unbounded) parallelism; validate settings#3110
JimBobSquarePants merged 1 commit intomainfrom
js/parallel-settings

Conversation

@JimBobSquarePants
Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

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:

  • Updated ParallelExecutionSettings to document and support -1 as an unbounded value for MaxDegreeOfParallelism, and clarified this in both the code and XML documentation. [1] [2] [3] [4]
  • Refactored the logic in ParallelRowIterator to support unbounded parallelism: introduced GetNumberOfSteps and CreateParallelOptions helpers, and adjusted how the number of steps and parallel options are calculated when MaxDegreeOfParallelism is -1. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Validation and safety enhancements:

  • Added ValidateSettings to ensure ParallelExecutionSettings are valid (e.g., MaxDegreeOfParallelism not zero or less than -1, MinimumPixelsProcessedPerTask > 0, and MemoryAllocator not null), guarding against invalid struct defaults and improving error messages.

Testing improvements:

  • Added tests to verify that using MaxDegreeOfParallelism = -1 results in all rows being processed, and that default (uninitialized) ParallelExecutionSettings throw appropriate exceptions. Introduced helper types for test operations. [1] [2] [3] [4]

@JimBobSquarePants JimBobSquarePants merged commit d3ca6eb into main Apr 9, 2026
12 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/parallel-settings branch April 9, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant