Skip to content

Commit e26f3e0

Browse files
committed
Merge branch 'master' into ccr
2 parents 08c2f55 + 867c496 commit e26f3e0

File tree

165 files changed

+6455
-1381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+6455
-1381
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.elasticsearch.benchmark.indices.breaker;
20+
21+
import org.openjdk.jmh.annotations.Benchmark;
22+
import org.openjdk.jmh.annotations.BenchmarkMode;
23+
import org.openjdk.jmh.annotations.Fork;
24+
import org.openjdk.jmh.annotations.Measurement;
25+
import org.openjdk.jmh.annotations.Mode;
26+
import org.openjdk.jmh.annotations.OutputTimeUnit;
27+
import org.openjdk.jmh.annotations.Param;
28+
import org.openjdk.jmh.annotations.Scope;
29+
import org.openjdk.jmh.annotations.State;
30+
import org.openjdk.jmh.annotations.Threads;
31+
import org.openjdk.jmh.annotations.Warmup;
32+
import org.openjdk.jmh.infra.Blackhole;
33+
34+
import java.lang.management.ManagementFactory;
35+
import java.lang.management.MemoryMXBean;
36+
import java.util.concurrent.TimeUnit;
37+
38+
@Fork(3)
39+
@Warmup(iterations = 10)
40+
@Measurement(iterations = 10)
41+
@BenchmarkMode(Mode.AverageTime)
42+
@OutputTimeUnit(TimeUnit.MICROSECONDS)
43+
@State(Scope.Benchmark)
44+
@SuppressWarnings("unused") //invoked by benchmarking framework
45+
public class MemoryStatsBenchmark {
46+
private static final MemoryMXBean MEMORY_MX_BEAN = ManagementFactory.getMemoryMXBean();
47+
48+
@Param({"0", "16", "256", "4096"})
49+
private int tokens;
50+
51+
@Benchmark
52+
public void baseline() {
53+
Blackhole.consumeCPU(tokens);
54+
}
55+
56+
@Benchmark
57+
@Threads(1)
58+
public long getMemoryStats_01() {
59+
Blackhole.consumeCPU(tokens);
60+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
61+
}
62+
63+
@Benchmark
64+
@Threads(2)
65+
public long getMemoryStats_02() {
66+
Blackhole.consumeCPU(tokens);
67+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
68+
}
69+
70+
@Benchmark
71+
@Threads(4)
72+
public long getMemoryStats_04() {
73+
Blackhole.consumeCPU(tokens);
74+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
75+
}
76+
77+
@Benchmark
78+
@Threads(8)
79+
public long getMemoryStats_08() {
80+
Blackhole.consumeCPU(tokens);
81+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
82+
}
83+
84+
@Benchmark
85+
@Threads(16)
86+
public long getMemoryStats_16() {
87+
Blackhole.consumeCPU(tokens);
88+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
89+
}
90+
91+
@Benchmark
92+
@Threads(32)
93+
public long getMemoryStats_32() {
94+
Blackhole.consumeCPU(tokens);
95+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
96+
}
97+
98+
@Benchmark
99+
@Threads(64)
100+
public long getMemoryStats_64() {
101+
Blackhole.consumeCPU(tokens);
102+
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
103+
}
104+
}
105+

buildSrc/src/main/groovy/org/elasticsearch/gradle/LoggedExec.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

buildSrc/src/main/groovy/org/elasticsearch/gradle/Version.groovy

Lines changed: 0 additions & 147 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.elasticsearch.gradle;
2+
3+
import org.gradle.api.GradleException;
4+
import org.gradle.api.tasks.Exec;
5+
6+
import java.io.ByteArrayOutputStream;
7+
import java.io.UnsupportedEncodingException;
8+
9+
/**
10+
* A wrapper around gradle's Exec task to capture output and log on error.
11+
*/
12+
@SuppressWarnings("unchecked")
13+
public class LoggedExec extends Exec {
14+
15+
protected ByteArrayOutputStream output = new ByteArrayOutputStream();
16+
17+
public LoggedExec() {
18+
if (getLogger().isInfoEnabled() == false) {
19+
setStandardOutput(output);
20+
setErrorOutput(output);
21+
setIgnoreExitValue(true);
22+
doLast((unused) -> {
23+
if (getExecResult().getExitValue() != 0) {
24+
try {
25+
for (String line : output.toString("UTF-8").split("\\R")) {
26+
getLogger().error(line);
27+
}
28+
} catch (UnsupportedEncodingException e) {
29+
throw new GradleException("Failed to read exec output", e);
30+
}
31+
throw new GradleException(
32+
String.format(
33+
"Process '%s %s' finished with non-zero exit value %d",
34+
getExecutable(),
35+
getArgs(),
36+
getExecResult().getExitValue()
37+
)
38+
);
39+
}
40+
}
41+
);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)