Skip to content

Optimize scrape target by using RLock in read methods#17306

Merged
machine424 merged 1 commit intoprometheus:mainfrom
AliNazariii:targets-rlock
Oct 8, 2025
Merged

Optimize scrape target by using RLock in read methods#17306
machine424 merged 1 commit intoprometheus:mainfrom
AliNazariii:targets-rlock

Conversation

@AliNazariii
Copy link
Contributor

@AliNazariii AliNazariii commented Oct 8, 2025

Which issue(s) does the PR fix:

Fixes #16549

Does this PR introduce a user-facing change?

[BUGFIX] API: Reduce lock contention on `/api/v1/targets`

Signed-off-by: Ali Nazari <ali4nazari4@gmail.com>
@AliNazariii
Copy link
Contributor Author

@machine424, PR is ready for review whenever you have time. Thanks.

@beorn7 beorn7 requested a review from machine424 October 8, 2025 10:17
Copy link
Member

@machine424 machine424 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for this!

For the release note, to make it clearer for end users, I’d suggest:
"[BUGFIX] API: Reduce lock contention on /api/v1/targets"

(I wouldn’t tag it as [PERF] or [ENHANCEMENT], since we don’t have numbers to back that up (it'll not be easy to benchmark this), let's consider it as a bug fix)

@AliNazariii
Copy link
Contributor Author

Thanks! Updated the release note as suggested.

@AliNazariii
Copy link
Contributor Author

@machine424, by the way, will you handle the merge, or should I wait for someone else to do it?

@machine424 machine424 merged commit 9e4d23d into prometheus:main Oct 8, 2025
29 checks passed
@AliNazariii AliNazariii deleted the targets-rlock branch October 9, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Target.URL() method should only need a read lock

2 participants