Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a set to keep track of metric ids for perf gains #2881

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

tzjames
Copy link
Collaborator

@tzjames tzjames commented Aug 15, 2024

Features and Changes

Speeds up organization/definitions route for orgs with a lot of metrics by looking up the metrics in O(1) time.

Testing

Ran

curl 'http://localhost:3100/organization/definitions' \
  -H 'Authorization: Bearer TOKEN_COPIED_FROM_BROWSER \
  -H 'X-Organization: ORG_ID_COPIED_FROM_BROWSER'  > before.out

applied the change and ran it again piping it to > after.out.
Then did diff before.out after.out and saw it return nothing.

Then did some benchmarking:

wrk -t1 -c1 -d30s \
  -H 'Authorization: Bearer COPIED FROM BROWSER REQUEST' \
  -H 'X-Organization: COPIED FROM BROWSER REQUEST' \
'http://localhost:3100/organization/definitions'

Before:

Running 30s test @ http://localhost:3100/organization/definitions
  1 threads and 1 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   425.98ms   59.91ms 778.62ms   94.29%
    Req/Sec     1.86      0.43     3.00     80.00%
  70 requests in 30.03s, 544.66MB read
Requests/sec:      2.33
Transfer/sec:     18.14MB

Using MetricId sets:

Running 30s test @ http://localhost:3100/organization/definitions
  1 threads and 1 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   327.55ms   77.21ms 576.97ms   90.00%
    Req/Sec     2.77      0.86     5.00     86.67%
  30 requests in 30.03s, 233.43MB read
  Socket errors: connect 0, read 75314, write 5356, timeout 0
Requests/sec:      1.00
Transfer/sec:      7.77MB

@tzjames tzjames requested a review from jdorn August 15, 2024 21:49
Copy link

Your preview environment pr-2881-bttf has been deployed.

Preview environment endpoints are available at:

@tzjames tzjames merged commit 9dfb981 into main Aug 15, 2024
3 checks passed
@tzjames tzjames deleted the ji/perf_metric_ids_set branch August 15, 2024 22:35
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.

2 participants