Skip to content

Lock contention performance issues:com.google.common.util.concurrent.RateLimiter#acquire(int) -->reserve()#synchronized #6205

Open

Description

image

I noticed RateLimiter recently and had a question in the ‘com.google.common.util.concurrent.RateLimiter#acquire(int)’ method。
What I want to ask is the performance issue of synchronized (mutex()) in reserve method.
If there are 10,000 requests to synchronize (mutex()) to compete for locks, then the semantics of synchronized will cause these requests to block here, which may cause lock escalation and eventually become heavyweight locks. Why not use optimistic locking to deal with it?

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions