-
Notifications
You must be signed in to change notification settings - Fork 10
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
Nested metric registries don't cause a sortedmap creation #430
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ffd4a48
Nested metric registries don't cause a sortedmap creation
j-baker 31021df
variable names
j-baker 6c114f2
Add generated changelog entries
j-baker 672cc35
return false
j-baker a2333e0
Small refactors
j-baker c8a2198
Benchmark
j-baker 27c3686
Add a forEach method on metrics
j-baker 161a4ed
Foreach optimized
j-baker 8a352e5
Add gc profiler
j-baker c17f181
Actually have another tag
j-baker 391b6dd
errorprone
j-baker 4843289
extra constructor
j-baker f8295fd
Deal with painful thing
j-baker bea4cb9
Add property based test for ExtraEntrySortedMap
CRogers 247cf99
Merge branch 'jbaker/faster_strings' of github.com:palantir/tritium i…
CRogers dfa341f
PR comments
j-baker b9db5cb
More PR comments
j-baker 75fbcb0
Stricter null checks
schlosna 5f5f61c
Suppress JDK Obsolete for SortedMap test
schlosna d8390ff
Fix copyright header
schlosna 31dc183
write locks
schlosna b26ad69
perf regression
j-baker bfe2efd
Merge pull request #431 from palantir/ds/faster-strings-cr
j-baker 969f8c0
Benchmark
j-baker 90456c8
Merge branch 'develop' into jbaker/faster_strings
j-baker 2b014f0
baseline...
j-baker 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 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 |
---|---|---|
|
@@ -32,3 +32,6 @@ out/ | |
|
||
# Gc logs | ||
build*.gc.log | ||
|
||
# Jqwik property based testing | ||
.jqwik-database |
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,5 @@ | ||
type: improvement | ||
improvement: | ||
description: Nested metric registries cause fewer allocations. | ||
links: | ||
- https://github.com/palantir/tritium/pull/430 |
100 changes: 100 additions & 0 deletions
100
tritium-jmh/src/jmh/java/com/palantir/tritium/microbenchmarks/NestedMetricsBenchmark.java
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,100 @@ | ||
/* | ||
* (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. | ||
* | ||
* 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. | ||
*/ | ||
|
||
package com.palantir.tritium.microbenchmarks; | ||
|
||
import com.codahale.metrics.Meter; | ||
import com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry; | ||
import com.palantir.tritium.metrics.registry.MetricName; | ||
import com.palantir.tritium.metrics.registry.TaggedMetricRegistry; | ||
import java.util.concurrent.TimeUnit; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
import org.openjdk.jmh.profile.GCProfiler; | ||
import org.openjdk.jmh.runner.Runner; | ||
import org.openjdk.jmh.runner.options.Options; | ||
import org.openjdk.jmh.runner.options.OptionsBuilder; | ||
|
||
@BenchmarkMode(Mode.AverageTime) | ||
@OutputTimeUnit(TimeUnit.NANOSECONDS) | ||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Fork(1) | ||
@State(Scope.Benchmark) | ||
@SuppressWarnings({"designforextension", "NullAway"}) | ||
public class NestedMetricsBenchmark { | ||
private TaggedMetricRegistry metrics; | ||
|
||
@Setup | ||
public void before() { | ||
metrics = constructBaseRegistry(); | ||
} | ||
|
||
@Benchmark | ||
public void benchmarkGetMetrics(Blackhole blackhole) { | ||
metrics.getMetrics().forEach((name, metric) -> { | ||
blackhole.consume(name); | ||
blackhole.consume(metric); | ||
}); | ||
} | ||
|
||
@Benchmark | ||
public void benchmarkForEach(Blackhole blackhole) { | ||
metrics.forEachMetric((name, metric) -> { | ||
blackhole.consume(name); | ||
blackhole.consume(metric); | ||
}); | ||
} | ||
|
||
private static TaggedMetricRegistry constructBaseRegistry() { | ||
TaggedMetricRegistry registry = new DefaultTaggedMetricRegistry(); | ||
for (int i = 0; i < 50; i++) { | ||
registry.addMetrics("registry id", Integer.toString(i), constructSubRegistry()); | ||
} | ||
return registry; | ||
} | ||
|
||
private static TaggedMetricRegistry constructSubRegistry() { | ||
TaggedMetricRegistry registry = new DefaultTaggedMetricRegistry(); | ||
for (int i = 0; i < 100; i++) { | ||
Meter meter = registry.meter(MetricName.builder() | ||
.safeName("some metric " + i) | ||
.putSafeTags("some tag", "some tag value") | ||
.build()); | ||
for (int j = 0; j < 1000; j++) { | ||
meter.mark(); | ||
} | ||
} | ||
return registry; | ||
} | ||
|
||
public static void main(String[] _args) throws Exception { | ||
Options opt = new OptionsBuilder() | ||
.include(NestedMetricsBenchmark.class.getSimpleName()) | ||
.addProfiler(GCProfiler.class) | ||
.build(); | ||
new Runner(opt).run(); | ||
} | ||
} |
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
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.
as updated by baseline
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.
assume we will also pick this up next time the robots do their rounds in https://github.com/palantir/gradle-baseline/releases/tag/2.7.0 though I don't see a tritium excavator listed in palantir/gradle-baseline#833