Skip to content
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

Add SafePoint times to UpdateGraphProcessor cycle times logging. #2123

Merged
merged 17 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Base/src/main/java/io/deephaven/base/MathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,43 @@ public static int gcd(int a, int b) {

return a;
}

private static final int[] tenToThe = new int[] {
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
};

/**
* Compute 10^n as a int for 0 <= n <= 9.
*
* @param n the exponent
* @return 10^n
*/
public static int pow10(int n) {
if (n < 0 || n > 9) {
throw new IllegalArgumentException("n = " + n);
}
return tenToThe[n];
}

private static final int[] base10guessFromBase2Digits = new int[] {
0, 0, 0, 0, 1, 1, 1, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 5, 5, 5,
6, 6, 6, 6, 7, 7, 7, 8, 8, 8,
9, 9, 9
};

/**
* Compute the number of base 10 digits in n's representation, for n >= 0.
*
* @param n an integer >= 0
* @return how many digits in n's base 10 representation.
*/
public static int base10digits(int n) {
int baseTwoDigits = 32 - Integer.numberOfLeadingZeros(n);
int base10guess = base10guessFromBase2Digits[baseTwoDigits];
if (n >= pow10(base10guess)) {
return 1 + base10guess;
}
return base10guess;
}
}
97 changes: 97 additions & 0 deletions IO/src/main/java/io/deephaven/io/log/LogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.deephaven.io.log;

import io.deephaven.base.MathUtil;
import io.deephaven.base.log.LogOutput;
import io.deephaven.base.log.LogOutputAppendable;
import io.deephaven.base.text.TimestampBuffer;
Expand Down Expand Up @@ -89,6 +90,102 @@ default LogEntry appendDouble(Double f) {
return f == null ? append("null") : appendDouble((double) f);
}

/**
* Append a double to the exact given number of decimal places, rounding half up.
*
* @param doubleValue a double value to append to the logEntry
* @param decimalPlaces a positive integer between 0 and 9
* @return the resulting {@code LogEntry}
*/
default LogEntry appendDouble(final double doubleValue, final int decimalPlaces) {
return appendDoubleDecimalPlacesImpl(this, doubleValue, decimalPlaces, decimalPlaces);
}

/**
* Append a double rounded to the given number of decimal places, rounding half up. If to the given decimal places
* of precision
*
* @param doubleValue a double value to append to the logEntry
* @param decimalPlaces a positive integer between 0 and 9 for the target number of decimal places to round to
* @param maxTrailingZeroesToDiscard a positive integer between 0 and 9 for the maximum trailing zeroes (if any) to
* discard from the fractional part of the result. The fractional part of the result will have always at
* least {@code (decimalPlaces - maxTrailingZeroesToDiscard)} places.
* @return the resulting {@code LogEntry}
*/
default LogEntry appendDouble(final double doubleValue, final int decimalPlaces,
final int maxTrailingZeroesToDiscard) {
return appendDoubleDecimalPlacesImpl(this, doubleValue, decimalPlaces,
decimalPlaces - maxTrailingZeroesToDiscard);
}

private static LogEntry appendDoubleDecimalPlacesImpl(
LogEntry entry, final double doubleValue, final int roundToDecimalPlaces, final int minDecimalPlaces) {
if (roundToDecimalPlaces < 0 || roundToDecimalPlaces > 9) {
throw new IllegalArgumentException("Invalid value for decimalPlaces = " + roundToDecimalPlaces);
}
final int roundToAsPowerOf10 = MathUtil.pow10(roundToDecimalPlaces);
final boolean negative = doubleValue < 0.0;
final long longWeightedValue;
if (negative) {
longWeightedValue = -(long) (-0.5 + doubleValue * roundToAsPowerOf10);
} else {
longWeightedValue = (long) (0.5 + doubleValue * roundToAsPowerOf10);
}
final long integral = longWeightedValue / roundToAsPowerOf10;
if (negative) {
entry = entry.append(-integral);
} else {
entry = entry.append(integral);
}
if (roundToDecimalPlaces == 0) {
return entry;
}
int fractional = (int) (longWeightedValue % roundToAsPowerOf10);
int actualDecimalPlaces = roundToDecimalPlaces;
while (minDecimalPlaces < actualDecimalPlaces && fractional > 0 && (fractional % 10 == 0)) {
fractional /= 10;
--actualDecimalPlaces;
}
if (minDecimalPlaces == 0 && fractional == 0) {
return entry;
}
entry = entry.append(".");
final int base10FractionalDigits = MathUtil.base10digits(fractional);
final int leadingZeroes = actualDecimalPlaces - base10FractionalDigits;
jcferretti marked this conversation as resolved.
Show resolved Hide resolved
switch (leadingZeroes) {
case 9:
entry = entry.append("000000000");
case 8:
entry = entry.append("00000000");
break;
case 7:
entry = entry.append("0000000");
break;
case 6:
entry = entry.append("000000");
break;
case 5:
entry = entry.append("00000");
break;
case 4:
entry = entry.append("0000");
break;
case 3:
entry = entry.append("000");
break;
case 2:
entry = entry.append("00");
break;
case 1:
entry = entry.append("0");
break;
}
if (fractional == 0) {
return entry;
}
return entry.append(fractional);
}

LogEntry nf();

LogEntry nl();
Expand Down
58 changes: 58 additions & 0 deletions IO/src/test/java/io/deephaven/io/log/impl/TestLogOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,62 @@ public void testBoolean() {
assertEquals("true", results[0]);
assertEquals("false", results[1]);
}

public void testPositiveDoubleToDecimalPlaces() {
logger.info().appendDouble(1.2345, 3).end();
logger.info().appendDouble(0.112255, 2).end();
logger.info().appendDouble(11111111.112255, 3).end();
logger.info().appendDouble(11111111.112255, 4).end();
logger.info().appendDouble(1111.4, 0).end();
logger.info().appendDouble(1111.5, 0).end();
logger.info().appendDouble(111.1234567894, 9).end();
logger.info().appendDouble(111.1234567895, 9).end();
logger.info().appendDouble(111.1234567895, 9, 9).end();
logger.info().appendDouble(111.123456789, 9).end();
logger.info().appendDouble(111.123456789, 9, 9).end();
logger.info().appendDouble(111.12, 4).end();
logger.info().appendDouble(111.12, 4, 4).end();
logger.info().appendDouble(111.14, 2).end();
logger.info().appendDouble(111.15, 2).end();
logger.info().appendDouble(111.15, 0).end();
logger.info().appendDouble(0, 0).end();
logger.info().appendDouble(0, 3).end();
logger.info().appendDouble(111.1995, 3).end();
logger.info().appendDouble(111.1995, 3, 1).end();
logger.info().appendDouble(111.1995, 3, 2).end();
logger.info().appendDouble(111.1995, 3, 3).end();
String[] results = logger.takeAll();
int c = 0;
assertEquals("1.235", results[c++]);
assertEquals("0.11", results[c++]);
assertEquals("11111111.112", results[c++]);
assertEquals("11111111.1123", results[c++]);
assertEquals("1111", results[c++]);
assertEquals("1112", results[c++]);
assertEquals("111.123456789", results[c++]);
assertEquals("111.123456790", results[c++]);
assertEquals("111.12345679", results[c++]);
assertEquals("111.123456789", results[c++]);
assertEquals("111.123456789", results[c++]);
assertEquals("111.1200", results[c++]);
assertEquals("111.12", results[c++]);
assertEquals("111.14", results[c++]);
assertEquals("111.15", results[c++]);
assertEquals("111", results[c++]);
assertEquals("0", results[c++]);
assertEquals("0.000", results[c++]);
assertEquals("111.200", results[c++]);
assertEquals("111.20", results[c++]);
assertEquals("111.2", results[c++]);
assertEquals("111.2", results[c++]);
}

public void testNegativeDoubleToDecimalPlaces() {
logger.info().appendDouble(-1.235, 2).end();
logger.info().appendDouble(-1.234, 2).end();
String[] results = logger.takeAll();
int c = 0;
assertEquals("-1.24", results[c++]);
assertEquals("-1.23", results[c++]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ tasks.withType(JavaCompile).configureEach {
options.incremental = true
options.compilerArgs << '-parameters'

def isTestCompile = name == 'compileTestJava'
if (isTestCompile) {
if (name == 'compileTestJava') {
if (compilerVersion != testLanguageLevel) {
options.release.set testLanguageLevel
}
Expand Down
2 changes: 1 addition & 1 deletion combined-javadoc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ def allJavadoc = tasks.register 'allJavadoc', Javadoc, {

artifacts {
combinedJavadoc allJavadoc
}
}
4 changes: 4 additions & 0 deletions debezium/perf/sample_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

results={}
for line in top_out:
line = line.strip()
for name, regex in name_pidre.items():
if re.search(regex, line) is not None:
cols = line.split(maxsplit=12)
Expand Down Expand Up @@ -90,6 +91,9 @@ def format_samples(precision : int, samples):
return s

with open(f'{out_dir}/{now_str}_top_samples.log', 'w') as f:
line = f'nsamples={args.nsamples}, delay_s={args.delay_s}'
print(line)
f.write(line + '\n')
for name in names:
result = results[name]
for tag in tags:
Expand Down
2 changes: 1 addition & 1 deletion docker/server-slim/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ configurations {
}

dependencies {
serverApplicationDist project(path: ':server-netty', configuration: 'applicationDist')
serverApplicationDist project(path: ':server-netty-app', configuration: 'applicationDist')
}

def dockerContext = project.layout.buildDirectory.dir('context')
Expand Down
2 changes: 1 addition & 1 deletion docker/server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ configurations {
}

dependencies {
serverApplicationDist project(path: ':server-netty', configuration: 'applicationDist')
serverApplicationDist project(path: ':server-netty-app', configuration: 'applicationDist')
}

def dockerLicenses = License.createFrom(project).syncDockerLicense().get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* milliseconds to avoid repeated calls that are not likely any different./p>
*
* <p>
* A dditionally, we log our JVM heap usage on a regular basis; to enable users to quickly examine their worker logs and
* Additionally, we log our JVM heap usage on a regular basis; to enable users to quickly examine their worker logs and
* understand memory issues.
* </p>
*/
Expand Down
1 change: 1 addition & 0 deletions engine/updategraph/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
api project(':qst')

implementation project(':engine-chunk')
implementation project(':hotspot')

compileOnly 'com.google.code.findbugs:jsr305:3.0.2'

Expand Down
Loading