-
Notifications
You must be signed in to change notification settings - Fork 4
test(integration): add GetChangedTargets benchmarks #204
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
Merged
+112
−8
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2f92525
test(integration): add GetChangedTargets benchmarks
yushan8 dde009d
test(integration): report benchmark timing in sec/op too
yushan8 e972920
fix(makefile): rename benchmark target to bench
yushan8 94986c1
Update
yushan8 91616b3
fix(makefile): increase benchtime to 20x
yushan8 b35d7e6
fix(makefile): set benchtime to 15x
yushan8 0c0edae
fix(makefile): use test.count=15 for benchmark iterations
yushan8 079e091
fix(makefile): remove stray line continuation in bench target
yushan8 ce06b4b
refactor(integration): use unique commit pairs for cold benchmarks
yushan8 36b209b
refactor(integration): revert to per-size benchmarks with benchtime=15x
yushan8 e7b5ff1
fix(integration): use stable commit pairs for cold benchmarks
yushan8 194508b
merge: resolve Makefile conflict with main
yushan8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Copyright (c) 2026 Uber Technologies, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| // Benchmarks for GetChangedTargets. Run via `make bench`; not part of | ||
| // `make test` / `make test-integration` and never from CI. | ||
| package integration_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "go.uber.org/zap" | ||
| "go.uber.org/zap/zapcore" | ||
| ) | ||
|
|
||
| // coldCommitPairs are distinct consecutive commit pairs from repo history. | ||
| // Each pair produces a unique treehash, guaranteeing a cache miss per call. | ||
| var coldCommitPairs = []struct{ first, second string }{ | ||
| {"57162624a45965a7e783072c56561f91c5d4084d", "74d1cd55155e5f4f43aa92b4e0146a0c528a0d96"}, | ||
| {"74d1cd55155e5f4f43aa92b4e0146a0c528a0d96", "3d54234a3d4c0d940d651e002c5c79d71f01b120"}, | ||
| {"3d54234a3d4c0d940d651e002c5c79d71f01b120", "821c885d304811652fefeeeb2c21e1907bebf7f6"}, | ||
| {"821c885d304811652fefeeeb2c21e1907bebf7f6", "ea874d203f37c58b9ba52cde81309d1e28827eaa"}, | ||
| {"ea874d203f37c58b9ba52cde81309d1e28827eaa", "c0cd90a8c35e2cc981e32f074f9a55657f44d7dd"}, | ||
| {"c0cd90a8c35e2cc981e32f074f9a55657f44d7dd", "8d7e7f93ea68bfb5e37f29df289a54ab8ff79ae1"}, | ||
| {"8d7e7f93ea68bfb5e37f29df289a54ab8ff79ae1", "4d41a6f57d2215db7e78c284f7f8f5e13f6ff07d"}, | ||
| {"4d41a6f57d2215db7e78c284f7f8f5e13f6ff07d", "b4591e33a40135ed5c2fef8ee4f96db8ab231904"}, | ||
| {"b4591e33a40135ed5c2fef8ee4f96db8ab231904", "f2b15a5e058ed0a678f97111080806e26d0239d4"}, | ||
| {"f2b15a5e058ed0a678f97111080806e26d0239d4", "fc7289244106a1a21a146729c6f75eb6d17f2649"}, | ||
| {"3662f8acd9fffb535e56b670beb0de0d811e4181", "381c6585a765e350326520d4e0a588bc604fa656"}, | ||
| {"381c6585a765e350326520d4e0a588bc604fa656", "450d404d4a337ec2809f28c630b126871a88987e"}, | ||
| {"450d404d4a337ec2809f28c630b126871a88987e", "3a07829426dc621d37bdbe2038ac85a20bec5ead"}, | ||
| {"3a07829426dc621d37bdbe2038ac85a20bec5ead", "7876d3870dd0da4ec94cb49362bb85247b373358"}, | ||
| {"7876d3870dd0da4ec94cb49362bb85247b373358", "9cc890fb7a91de8b129a3cc86f362b393655de5b"}, | ||
| } | ||
|
|
||
| // BenchmarkGetChangedTargets_Cold measures uncached GetChangedTargets calls. | ||
| // Each iteration uses a different commit pair so every call is a cache miss, | ||
| // exercising the full pipeline: git checkout, bazel query, compare, stream. | ||
| func BenchmarkGetChangedTargets_Cold(b *testing.B) { | ||
| remote := repoRemote(b) | ||
| logger := zap.New(zapcore.NewNopCore()) | ||
| addr := startServerWithLogger(b, remote, logger) | ||
| client := newClient(b, addr) | ||
| b.ResetTimer() | ||
| for i := 0; i < b.N; i++ { | ||
| pair := coldCommitPairs[i] | ||
| getChangedTargets(b, client, remote, pair.first, pair.second) | ||
| } | ||
| } | ||
|
|
||
| // BenchmarkGetChangedTargets_Cached measures cached GetChangedTargets calls. | ||
| // The cache is primed with a single call before the timed loop, so every | ||
| // iteration in the loop is a cache hit measuring streaming overhead only. | ||
| func BenchmarkGetChangedTargets_Cached(b *testing.B) { | ||
| remote := repoRemote(b) | ||
| logger := zap.New(zapcore.NewNopCore()) | ||
| addr := startServerWithLogger(b, remote, logger) | ||
| client := newClient(b, addr) | ||
|
|
||
| firstSHA := "57162624a45965a7e783072c56561f91c5d4084d" | ||
| secondSHA := "74d1cd55155e5f4f43aa92b4e0146a0c528a0d96" | ||
|
|
||
| getChangedTargets(b, client, remote, firstSHA, secondSHA) | ||
|
|
||
| b.ResetTimer() | ||
| for i := 0; i < b.N; i++ { | ||
| getChangedTargets(b, client, remote, firstSHA, secondSHA) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's run it with higher iteration by default. like 15 or 20.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided changed the test to run
getChangedTargetson different commits to test cold cache calls. Since each iteration needs a unique commit pair for a cache miss, b.N is capped at the number of pairs we have.BenchmarkGetChangedTargets_Coldtests for the requests with cache miss (full bazel query) with 15 distinctive commit pairs, while the otherBenchmarkGetChangedTargets_Cachedtests for the duration of cache hits.This lets us measure the endpoint latency without the server startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated benchtime to run 15x