-
Notifications
You must be signed in to change notification settings - Fork 9
Add the micro-benchmark for thread filtering #237
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
Merged
Changes from all commits
Commits
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
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
2 changes: 1 addition & 1 deletion
2
...tresstest/scenarios/CapturingLambdas.java → .../scenarios/counters/CapturingLambdas.java
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
2 changes: 1 addition & 1 deletion
2
...r/stresstest/scenarios/DumpRecording.java → ...est/scenarios/counters/DumpRecording.java
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
2 changes: 1 addition & 1 deletion
2
...r/stresstest/scenarios/GraphMutation.java → ...est/scenarios/counters/GraphMutation.java
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
2 changes: 1 addition & 1 deletion
2
...iler/stresstest/scenarios/GraphState.java → ...sstest/scenarios/counters/GraphState.java
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
2 changes: 1 addition & 1 deletion
2
...ofiler/stresstest/scenarios/NanoTime.java → ...resstest/scenarios/counters/NanoTime.java
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
3 changes: 1 addition & 2 deletions
3
...test/scenarios/ThreadFilterBenchmark.java → ...arios/counters/ThreadFilterBenchmark.java
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
2 changes: 1 addition & 1 deletion
2
...esstest/scenarios/TracedParallelWork.java → ...cenarios/counters/TracedParallelWork.java
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
113 changes: 113 additions & 0 deletions
113
...mh/java/com/datadoghq/profiler/stresstest/scenarios/throughput/ThreadFilterBenchmark.java
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,113 @@ | ||
package com.datadoghq.profiler.stresstest.scenarios.throughput; | ||
|
||
import com.datadoghq.profiler.JavaProfiler; | ||
import com.datadoghq.profiler.stresstest.Configuration; | ||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.Level; | ||
import org.openjdk.jmh.annotations.Measurement; | ||
import org.openjdk.jmh.annotations.Mode; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.annotations.Param; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.Setup; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.annotations.Threads; | ||
import org.openjdk.jmh.annotations.Warmup; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@State(Scope.Benchmark) | ||
public class ThreadFilterBenchmark extends Configuration { | ||
private JavaProfiler profiler; | ||
|
||
@Param(BASE_COMMAND + ",filter=1") | ||
public String command; | ||
|
||
@Param("true") | ||
public String skipResults; | ||
|
||
@Param({"0", "7", "70000"}) | ||
public String workload; | ||
|
||
private long workloadNum = 0; | ||
|
||
@Setup(Level.Trial) | ||
public void setup() throws IOException { | ||
profiler = JavaProfiler.getInstance(); | ||
workloadNum = Long.parseLong(workload); | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.Throughput) | ||
@Fork(value = 3, warmups = 3) | ||
@Warmup(iterations = 5) | ||
@Measurement(iterations = 8) | ||
@Threads(1) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void threadFilterStress01() throws InterruptedException { | ||
profiler.addThread(); | ||
// Simulate per-thread work | ||
Blackhole.consumeCPU(workloadNum); | ||
profiler.removeThread(); | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.Throughput) | ||
@Fork(value = 3, warmups = 3) | ||
@Warmup(iterations = 5) | ||
@Measurement(iterations = 8) | ||
@Threads(2) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void threadFilterStress02() throws InterruptedException { | ||
profiler.addThread(); | ||
// Simulate per-thread work | ||
Blackhole.consumeCPU(workloadNum); | ||
profiler.removeThread(); | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.Throughput) | ||
@Fork(value = 3, warmups = 3) | ||
@Warmup(iterations = 5) | ||
@Measurement(iterations = 8) | ||
@Threads(4) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void threadFilterStress04() throws InterruptedException { | ||
profiler.addThread(); | ||
// Simulate per-thread work | ||
Blackhole.consumeCPU(workloadNum); | ||
profiler.removeThread(); | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.Throughput) | ||
@Fork(value = 3, warmups = 3) | ||
@Warmup(iterations = 5) | ||
@Measurement(iterations = 8) | ||
@Threads(8) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void threadFilterStress08() throws InterruptedException { | ||
profiler.addThread(); | ||
// Simulate per-thread work | ||
Blackhole.consumeCPU(workloadNum); | ||
profiler.removeThread(); | ||
} | ||
|
||
@Benchmark | ||
@BenchmarkMode(Mode.Throughput) | ||
@Fork(value = 3, warmups = 3) | ||
@Warmup(iterations = 5) | ||
@Measurement(iterations = 8) | ||
@Threads(16) | ||
@OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
public void threadFilterStress16() throws InterruptedException { | ||
profiler.addThread(); | ||
// Simulate per-thread work | ||
Blackhole.consumeCPU(workloadNum); | ||
profiler.removeThread(); | ||
} | ||
} |
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.
🟠 Code Quality Violation
Remove initialization, this is already the default value. (...read more)
When initializing fields, prevent initializing fields to the default value. Any additional initialization means more bytecode instructions, and allocating many of these objects may impact your application performance.
If you initialize to a default value, remove the initialization.