Skip to content

Unlimited rate limiters consume CPU while idle #166

Description

@dwisiswant0

NewUnlimited creates a goroutine and a 1 ms ticker for each limiter. These keep running without requests, and every Take requires a channel exchange.

This cost multiplies in Subfinder, URLFinder, and TLDFinder, which create unlimited limiters per source. Local benchmarks measured approximately 1.47 seconds of CPU per wall-clock second for 1,000 idle limiters.

To reproduce, create multiple NewUnlimited(context.Background()) instances, issue no requests, and measure process CPU usage.

Unlimited mode should permit requests without a ticker, worker, or token exchange. The fix should preserve GetLimit, runtime setter behavior, and safe handling of Stop.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type: OptimizationIncreasing the performance/optimization. Not an issue, just something to consider.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions