Skip to content

Commit 6995b60

Browse files
committed
make hpy upcall trace output interval configurable
1 parent cbfc210 commit 6995b60

File tree

1 file changed

+23
-3
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy

1 file changed

+23
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/hpy/GraalHPyContext.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,27 @@
270270
@ExportLibrary(value = NativeTypeLibrary.class, useForAOT = false)
271271
public class GraalHPyContext extends CExtContext implements TruffleObject {
272272

273-
private static final boolean TRACE = Boolean.getBoolean("HPyTraceUpcalls");
273+
private static final boolean TRACE;
274+
private static final int TRACE_SLEEP_TIME;
275+
static {
276+
String prop = System.getProperty("HPyTraceUpcalls");
277+
boolean doTrace = false;
278+
int sleepTime = 5000;
279+
if (prop != null) {
280+
if (prop.equals("true")) {
281+
doTrace = true;
282+
} else {
283+
try {
284+
sleepTime = Integer.parseInt(prop);
285+
doTrace = true;
286+
} catch (NumberFormatException e) {
287+
// pass
288+
}
289+
}
290+
}
291+
TRACE = doTrace;
292+
TRACE_SLEEP_TIME = sleepTime;
293+
}
274294

275295
private static final TruffleLogger LOGGER = PythonLanguage.getLogger(GraalHPyContext.class);
276296

@@ -1388,7 +1408,7 @@ void increment() {
13881408

13891409
while (true) {
13901410
try {
1391-
Thread.sleep(5000);
1411+
Thread.sleep(TRACE_SLEEP_TIME);
13921412
} catch (InterruptedException e) {
13931413
// fall through
13941414
}
@@ -2261,7 +2281,7 @@ private static Object[] createMembers(PythonContext context, String name) {
22612281
public void run() {
22622282
while (true) {
22632283
try {
2264-
Thread.sleep(5000);
2284+
Thread.sleep(TRACE_SLEEP_TIME);
22652285
} catch (InterruptedException e) {
22662286
e.printStackTrace();
22672287
}

0 commit comments

Comments
 (0)