-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define a custom Scope Key for reducing memory allocations (#116)
* save progress * revert to master * sync with master * add gradle files * gradle cleanup * add unit tests and cleanup code * self review * self review * review comments address * fix flaky test as pointed in review * add benchmark * self review * nit pick
- Loading branch information
1 parent
23c39f9
commit fa530e2
Showing
12 changed files
with
263 additions
and
128 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,9 +1,35 @@ | ||
Benchmark Mode Cnt Score Error Units | ||
ScopeImplBenchmark.scopeReportingBenchmark thrpt 10 1385.711 ± 55.291 ops/ms | ||
ScopeImplBenchmark.scopeReportingBenchmark:·async thrpt NaN --- | ||
ScopeImplBenchmark.scopeReportingBenchmark:·gc.alloc.rate thrpt 10 ≈ 10⁻⁴ MB/sec | ||
ScopeImplBenchmark.scopeReportingBenchmark:·gc.alloc.rate.norm thrpt 10 ≈ 10⁻⁴ B/op | ||
ScopeImplBenchmark.scopeReportingBenchmark:·gc.count thrpt 10 ≈ 0 counts | ||
ScopeImplBenchmark.scopeReportingBenchmark:·threads.alive thrpt 10 5.800 ± 0.637 threads | ||
ScopeImplBenchmark.scopeReportingBenchmark:·threads.daemon thrpt 10 4.000 ± 0.001 threads | ||
ScopeImplBenchmark.scopeReportingBenchmark:·threads.started thrpt 10 26.000 threads | ||
Benchmark Mode Cnt Score Error Units | ||
ScopeImplBenchmark.scopeReportingBenchmark thrpt 10 1345.606 ± 129.913 ops/ms | ||
ScopeImplBenchmark.scopeReportingBenchmark:·async thrpt NaN --- | ||
ScopeImplBenchmark.scopeReportingBenchmark:·gc.alloc.rate thrpt 10 ≈ 10⁻⁴ MB/sec | ||
ScopeImplBenchmark.scopeReportingBenchmark:·gc.alloc.rate.norm thrpt 10 ≈ 10⁻⁴ B/op | ||
ScopeImplBenchmark.scopeReportingBenchmark:·gc.count thrpt 10 ≈ 0 counts | ||
ScopeImplBenchmark.scopeReportingBenchmark:·threads.alive thrpt 10 5.800 ± 0.637 threads | ||
ScopeImplBenchmark.scopeReportingBenchmark:·threads.daemon thrpt 10 4.000 ± 0.001 threads | ||
ScopeImplBenchmark.scopeReportingBenchmark:·threads.started thrpt 10 26.000 threads | ||
ScopeImplBenchmark.scopeTaggedBenchmark thrpt 10 2440.881 ± 73.028 ops/ms | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·async thrpt NaN --- | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.alloc.rate thrpt 10 1947.506 ± 58.647 MB/sec | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.alloc.rate.norm thrpt 10 880.000 ± 0.001 B/op | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.churn.G1_Eden_Space thrpt 10 1940.575 ± 57.874 MB/sec | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.churn.G1_Eden_Space.norm thrpt 10 876.878 ± 5.246 B/op | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.churn.G1_Old_Gen thrpt 10 0.168 ± 0.001 MB/sec | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.churn.G1_Old_Gen.norm thrpt 10 0.076 ± 0.002 B/op | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.count thrpt 10 1736.000 counts | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·gc.time thrpt 10 1772.000 ms | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·threads.alive thrpt 10 5.800 ± 0.637 threads | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·threads.daemon thrpt 10 4.000 ± 0.001 threads | ||
ScopeImplBenchmark.scopeTaggedBenchmark:·threads.started thrpt 10 26.000 threads | ||
ScopeImplConcurrent.hotkeyLockContention thrpt 10 1.430 ± 0.218 ops/ms | ||
ScopeImplConcurrent.hotkeyLockContention:·async thrpt NaN --- | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.alloc.rate thrpt 10 1244.444 ± 187.772 MB/sec | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.alloc.rate.norm thrpt 10 960144.037 ± 0.011 B/op | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.churn.G1_Eden_Space thrpt 10 1237.763 ± 186.894 MB/sec | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.churn.G1_Eden_Space.norm thrpt 10 954972.637 ± 4468.064 B/op | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.churn.G1_Old_Gen thrpt 10 0.166 ± 0.001 MB/sec | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.churn.G1_Old_Gen.norm thrpt 10 129.528 ± 18.631 B/op | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.count thrpt 10 1564.000 counts | ||
ScopeImplConcurrent.hotkeyLockContention:·gc.time thrpt 10 1336.000 ms | ||
ScopeImplConcurrent.hotkeyLockContention:·threads.alive thrpt 10 5.800 ± 0.637 threads | ||
ScopeImplConcurrent.hotkeyLockContention:·threads.daemon thrpt 10 4.000 ± 0.001 threads | ||
ScopeImplConcurrent.hotkeyLockContention:·threads.started thrpt 10 26.000 threads |
This file contains 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 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,3 @@ | ||
#bprof=async:event=cpu;direction=forward;output=flamegraph;dir=profile-results;libPath=<path-to-libasyncProfiler.so> | ||
#benchclass=ScopeImplBenchmark.* | ||
#output=benchmark-new.txt |
This file contains 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 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 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 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,60 @@ | ||
// Copyright (c) 2023 Uber Technologies, Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package com.uber.m3.tally; | ||
|
||
import com.uber.m3.util.ImmutableMap; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* ScopeKey encapsulates the data to uniquely identify the {@link Scope}. | ||
* This object overrides {@link #equals(Object)} and {@link #hashCode()} methods, so it can be used in Hash based {@link java.util.Map} implementations, to retrieve the corresponding {@link Scope}. | ||
*/ | ||
public final class ScopeKey { | ||
private final String prefix; | ||
private final ImmutableMap<String, String> tags; | ||
|
||
public ScopeKey(String prefix, ImmutableMap<String, String> tags) { | ||
this.prefix = prefix; | ||
this.tags = tags; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(prefix, tags); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object otherObj) { | ||
if (this == otherObj) { | ||
return true; | ||
} | ||
if (otherObj == null) { | ||
return false; | ||
} | ||
if (getClass() != otherObj.getClass()) { | ||
return false; | ||
} | ||
ScopeKey other = (ScopeKey) otherObj; | ||
return Objects.equals(this.prefix, other.prefix) && Objects.equals(this.tags, other.tags); | ||
} | ||
|
||
} |
Oops, something went wrong.