Skip to content

[Improvements] ServiceManager.cs — Parallel.ForEach parallelism uncapped at ProcessorCount #504

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Info

File: src/Servy.Core/Services/ServiceManager.cs, line 886

Description:
GetAllServices uses Parallel.ForEach with MaxDegreeOfParallelism = Environment.ProcessorCount. On a 64-core server, this spawns 64 concurrent P/Invoke threads making OpenService calls against the SCM simultaneously.

The ExecuteBulkOperationAsync in the Manager already caps at Math.Min(Environment.ProcessorCount * 2, 8). The GetAllServices parallelism should have a similar cap.

Suggested fix:
Cap MaxDegreeOfParallelism at 8–16 regardless of core count, consistent with the bulk operation pattern.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions