Skip to content

Acquiring a Semaphore is O(n) in the Semaphore value #90

@dmurvihill

Description

@dmurvihill

See this line in _drainUnlockWaiters:

            for (let weight = this._value; weight > 0; weight--) {

and a second one below.

This impacts performance when using Semaphores with very large values, such as 2147483628.

Performing this operation efficiently may not be trivial as the best data structure is highly situation-dependent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions