Skip to content

Commit

Permalink
Do not show statistics on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jan 14, 2025
1 parent 96d5a14 commit 7ad3018
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
9 changes: 0 additions & 9 deletions mx.trufflesqueak/mx_trufflesqueak.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ def _add_unit_tests(tasks, supports_coverage):
"--enable-timing",
]
)
if _COMPILER:
unittest_args.extend(
[
"-Dgraal.CompilationFailureAction=ExitVM",
"-Dpolyglot.compiler.TreatPerformanceWarningsAsErrors=call,instanceof,store,trivial",
"-Dpolyglot.engine.CompilationFailureAction=ExitVM",
"-Dpolyglot.engine.CompilationStatistics=true",
]
)

# Ensure Truffle TCK disabled (workaround needed since GraalVM 19.2.0)
# import mx_truffle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Context.Builder;
import org.graalvm.polyglot.Engine;

import com.oracle.truffle.api.nodes.IndirectCallNode;

Expand All @@ -34,11 +35,18 @@
import de.hpi.swa.trufflesqueak.util.FrameAccess;

public abstract class AbstractSqueakTestCase {
private static final boolean IS_GRAAL_RUNTIME;

protected static Context context;
protected static SqueakImageContext image;
protected static PointersObject nilClassBinding;

static {
try (Engine engine = Engine.create()) {
IS_GRAAL_RUNTIME = engine.getImplementationName().contains("Graal");
}
}

protected static final CompiledCodeObject makeMethod(final byte[] bytes, final long header, final Object[] literals) {
return new CompiledCodeObject(image, bytes, header, literals, image.compiledMethodClass);
}
Expand Down Expand Up @@ -90,14 +98,23 @@ protected static final Object runPrimitive(final int primCode, final Object rcvr
return ((Primitive4) PrimitiveNodeFactory.getOrCreateIndexed(primCode, 5)).execute(null, rcvr, arg1, arg2, arg3, arg4);
}

protected static final SqueakImage loadImageContext(final String imagePath) {
protected record TestImageSpec(String imagePath, boolean showStatistics) {
}

protected static final SqueakImage loadImageContext(final TestImageSpec spec) {
assert context == null && image == null;
final Builder contextBuilder = Context.newBuilder();
contextBuilder.allowAllAccess(true);
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.IMAGE_PATH, imagePath);
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.IMAGE_PATH, spec.imagePath);
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.HEADLESS, "true");
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.RESOURCE_SUMMARY, "true");
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.TESTING, "true");
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.RESOURCE_SUMMARY, Boolean.toString(spec.showStatistics));
if (IS_GRAAL_RUNTIME) {
contextBuilder.option("engine.CompilationStatistics", Boolean.toString(spec.showStatistics));
contextBuilder.option("compiler.TreatPerformanceWarningsAsErrors", "call,instanceof,store,trivial");
contextBuilder.option("engine.CompilationFailureAction", "ExitVM");
}

final String logLevel = System.getProperty("log.level");
if (logLevel != null) {
contextBuilder.option("log." + SqueakLanguageConfig.ID + ".level", logLevel);
Expand All @@ -109,7 +126,7 @@ protected static final SqueakImage loadImageContext(final String imagePath) {
context.enter();
try {
image = SqueakImageContext.getSlow();
if (Files.exists(Paths.get(imagePath))) {
if (Files.exists(Paths.get(spec.imagePath))) {
image.ensureLoaded();
}
return image.getSqueakImage(); // Pretend image has been loaded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class AbstractSqueakTestCaseWithDummyImage extends AbstractSquea
@BeforeClass
public static void setUpSqueakImageContext() {
SqueakImageContext.initializeBeforeLoadingImage();
loadImageContext("fake.image");
loadImageContext(new TestImageSpec("fake.image", false));
final Object[] dummySpecialObjects = new Object[100];
final ArrayObject dummySpecialSelectors = createDummySpecialSelectors();
dummySpecialObjects[SPECIAL_OBJECT.SPECIAL_SELECTORS] = dummySpecialSelectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public static void setUp() {
}

public static void loadTestImage() {
loadTestImage(true);
loadTestImage(true, true);
}

private static void loadTestImage(final boolean retry) {
private static void loadTestImage(final boolean retry, final boolean showResourceSummary) {
executor = Executors.newSingleThreadExecutor();
final String imagePath = getPathToTestImage();
try {
runWithTimeout(imagePath, AbstractSqueakTestCase::loadImageContext, TEST_IMAGE_LOAD_TIMEOUT_SECONDS);
runWithTimeout(new TestImageSpec(imagePath, showResourceSummary), AbstractSqueakTestCase::loadImageContext, TEST_IMAGE_LOAD_TIMEOUT_SECONDS);
println("Test image loaded from " + imagePath + "...");
patchImageForTesting();
} catch (final InterruptedException e) {
Expand Down Expand Up @@ -95,7 +95,7 @@ public static void cleanUp() {

protected static void reloadImage() {
cleanUp();
loadTestImage(false);
loadTestImage(false, false);
}

private static void patchImageForTesting() {
Expand Down

1 comment on commit 7ad3018

@TruffleSqueak-Bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance Report (7ad3018)

Benchmarks ran on 23.0.1-graal.

Steady (after 100 iterations)

Benchmark Name Min Geomean Median Mean Max Total (ms) Total (min)
Bounce 524 537 528.46 525 528.44 105691 1.76
CD 490 508 495.62 492 495.58 99123 1.65
DeltaBlue 274 376 343.1 344 342.81 68620 1.14
Havlak 1205 1272 1239.31 1239.5 1239.25 247862 4.13
Json 327 344 331.1 328 331.05 66219 1.1
List 318 344 320.64 319 320.59 64127 1.07
Mandelbrot 129 149 130.64 130 130.61 26127 0.44
NBody 246 267 250.08 247 250.02 50015 0.83
Permute 155 201 158.92 156 158.61 31783 0.53
Queens 219 271 242.66 240 242.58 48532 0.81
Richards 1242 1259 1247.8 1245 1247.79 249559 4.16
Sieve 170 183 171.2 171 171.18 34239 0.57
Storage 138 156 142.04 140 141.96 28407 0.47
Towers 175 198 177.06 176 177 35411 0.59
5612 6065 5778.58 5752.5 5777.45 1155715 19.26

7ad3018-2-steady.svg

Warmup (first 100 iterations)

7ad3018-3-warmup.svg

Please sign in to comment.