-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
statcache: add bench for LRU/mapCache #45277
Conversation
/retest |
7648328
to
8857a4f
Compare
f7b8b14
to
10e58cf
Compare
/test tiprow_fast_test |
@hawkingrei: The specified target(s) for
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test tiprow_fast_test |
@hawkingrei: The specified target(s) for
Use
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
10e58cf
to
4764294
Compare
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
@@ -110,6 +125,8 @@ func (m *MapCache) Values() []*statistics.Table { | |||
|
|||
// Map implements StatsCacheInner | |||
func (m *MapCache) Map() map[int64]*statistics.Table { |
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.
This method can be removed.
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.
Done
wg.Add(1) | ||
go func(i int) { | ||
defer wg.Done() | ||
t1 := testutil.NewMockStatisticsTable(1, 1, true, false, false) |
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.
It seems like we don't need to create a new table object each time? Otherwise this creation operation may affect the bench result.
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.
unfortunately, When using the CopyAndUpdate
, it will use the table id of structure.
so we make this structure difference. So it impacts each benchmark, which means it has no impact.
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.
we need to insert the map and not update the map. so we need to make this structure difference.
|
||
const defaultSize int64 = 1000 | ||
|
||
func BenchmarkLruPut(b *testing.B) { |
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.
It seems like BenchmarkLRUXXX
is duplicated with BenchmarkMapXXX
.
Why not we implement these benchmark methods on StastCacheInner
interface, then we can remove some duplicated code, for example:
func benchmarkStatsCacheInner(b, c) {
...
}
func Benchmark(b) {
for c := []Cache{LRU, Map} {
benchmarkStatsCacheInner(b, c)
}
}
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.
Done
Signed-off-by: Weizhen Wang <[email protected]>
Signed-off-by: Weizhen Wang <[email protected]>
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 thought that COW guarantees that mapcache don't need to be thread-safe. Will any race condition happen in the current master code?
Signed-off-by: Weizhen Wang <[email protected]>
This is my mistake. I brought the code for the next PR into this one. Now it is reverted. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qw4990, xuyifangreeneyes The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
What problem does this PR solve?
Issue Number: ref #45281
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.