Skip to content
Open
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
1 change: 1 addition & 0 deletions ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
[bench]: bench_task(bench) + platform_spec(no_jobs) + bench_variants({
"vm_name:graalvm_ce_default_interpreter" : {"linux:amd64:jdk-latest" : on_demand + t("02:00:00")},
"vm_name:graalvm_ee_default_interpreter" : {"linux:amd64:jdk-latest" : daily + t("02:00:00") + need_pgo},
"vm_name:graalvm_ee_default_interpreter_uncached" : {"linux:amd64:jdk-latest" : daily + t("02:00:00") + need_pgo},
"vm_name:graalpython_core_interpreter" : {"linux:amd64:jdk-latest" : on_demand + t("02:00:00")},
"vm_name:graalpython_core_native_interpreter" : {"linux:amd64:jdk-latest" : on_demand + t("02:00:00")},
"vm_name:graalpython_enterprise_interpreter" : {"linux:amd64:jdk-latest" : weekly + t("02:00:00")},
Expand Down
6 changes: 6 additions & 0 deletions ci/constants.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
default_multi: "default-multi",
interpreter: "interpreter",
interpreter_manual: "interpreter-manual",
interpreter_uncached: "interpreter-uncached",
native_interpreter: "native-interpreter",
native_interpreter_manual: "native-interpreter-manual",
interpreter_multi: "interpreter-multi",
Expand Down Expand Up @@ -140,6 +141,10 @@
python_vm: PYVM.graalpython,
python_vm_config: PYVM_CONFIG.interpreter_manual,
},
graalpython_interpreter_uncached: {
python_vm: PYVM.graalpython,
python_vm_config: PYVM_CONFIG.interpreter_uncached,
},
graalpython_native_interpreter: {
python_vm: PYVM.graalpython,
python_vm_config: PYVM_CONFIG.native_interpreter,
Expand Down Expand Up @@ -239,6 +244,7 @@
graalvm_ee_default: PYTHON_VM.graalpython + JVM_VM.graal_native_image_ee,
graalvm_ee_default_manual: PYTHON_VM.graalpython_manual + JVM_VM.graal_native_image_ee,
graalvm_ee_default_interpreter: PYTHON_VM.graalpython_interpreter + JVM_VM.graal_native_image_ee,
graalvm_ee_default_interpreter_uncached: PYTHON_VM.graalpython_interpreter_uncached + JVM_VM.graal_native_image_ee,
graalvm_ee_default_interpreter_manual: PYTHON_VM.graalpython_interpreter_manual + JVM_VM.graal_native_image_ee,
graalvm_ce_default_multi_tier: PYTHON_VM.graalpython_multi_tier + JVM_VM.graal_native_image_ce,
graalvm_ee_default_multi_tier: PYTHON_VM.graalpython_multi_tier + JVM_VM.graal_native_image_ee,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ def run_benchmark(args):

if GRAALPYTHON:
print(f"### using bytecode DSL interpreter: {__graalpython__.is_bytecode_dsl_interpreter}")
print(f"### using forced uncached interpreter: {getattr(__graalpython__, "is_forced_uncached_interpreter", False)}")

BenchRunner(bench_file, bench_args=bench_args, iterations=iterations, warmup=warmup, warmup_runs=warmup_runs, startup=startup, live_results=live_results, self_measurement=self_measurement).run()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,11 @@ public void initialize(Python3Core core) {
addBuiltinConstant("is_native", TruffleOptions.AOT);
addBuiltinConstant("is_bytecode_dsl_interpreter", PythonOptions.ENABLE_BYTECODE_DSL_INTERPRETER);
PythonContext ctx = core.getContext();
TruffleString encodingOpt = ctx.getLanguage().getEngineOption(PythonOptions.StandardStreamEncoding);
PythonLanguage language = ctx.getLanguage();
// Engine options: if they differ from the values baked into the pre-initialized context,
// this `initialize` method is run again.
addBuiltinConstant("is_forced_uncached_interpreter", language.getEngineOption(PythonOptions.ForceUncachedInterpreter));
TruffleString encodingOpt = language.getEngineOption(PythonOptions.StandardStreamEncoding);
TruffleString standardStreamEncoding = null;
TruffleString standardStreamError = null;
if (encodingOpt != null && !encodingOpt.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,7 @@ public void setMetadata(BytecodeDSLCodeUnit co, ParserCallbacksImpl parserErrorC
}
instrumentationDataIndex = co.instrumentationDataIndex;
yieldFromGeneratorIndex = co.yieldFromGeneratorIndex;
if (PythonOptions.UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT != -1) {
getBytecodeNode().setUncachedThreshold(PythonOptions.UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT);
}
PythonOptions.setUncachedInterpreterThreshold(getLanguage(), getBytecodeNode());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Option;
import com.oracle.truffle.api.TruffleLanguage.Env;
import com.oracle.truffle.api.bytecode.BytecodeNode;
import com.oracle.truffle.api.dsl.Idempotent;
import com.oracle.truffle.api.exception.AbstractTruffleException;
import com.oracle.truffle.api.nodes.ExplodeLoop;
Expand All @@ -88,7 +89,6 @@ public final class PythonOptions {
* bytecode interpreter.
*/
public static final boolean ENABLE_BYTECODE_DSL_INTERPRETER;
public static final int UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT;
private static final OptionType<TruffleString> TS_OPTION_TYPE = new OptionType<>("graal.python.TruffleString", PythonUtils::toTruffleStringUncached);

static {
Expand All @@ -107,17 +107,6 @@ public final class PythonOptions {
} else {
ENABLE_BYTECODE_DSL_INTERPRETER = true;
}

if (Boolean.getBoolean("python.ForceUncachedInterpreter")) {
UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT = Integer.MIN_VALUE;
} else {
String uncachedLimitStr = System.getProperty("python.UncachedInterpreterLimit");
if (uncachedLimitStr != null) {
UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT = Integer.parseInt(uncachedLimitStr);
} else {
UNCACHED_BYTECODE_DSL_INTERPRETER_LIMIT = -1;
}
}
}

private PythonOptions() {
Expand Down Expand Up @@ -440,6 +429,12 @@ public static void checkBytecodeDSLEnv() {
such as when settrace instrumentation is enabled. This option avoids rereading bytecode files by keeping the original bytecode form in memory""") //
public static final OptionKey<Boolean> KeepBytecodeInMemory = new OptionKey<>(false);

@EngineOption @Option(category = OptionCategory.INTERNAL, help = "", stability = OptionStability.EXPERIMENTAL) //
public static final OptionKey<Boolean> ForceUncachedInterpreter = new OptionKey<>(false);

@EngineOption @Option(category = OptionCategory.INTERNAL, help = "", stability = OptionStability.EXPERIMENTAL) //
public static final OptionKey<Integer> UncachedInterpreterThreshold = new OptionKey<>(-1);

public static final OptionDescriptors DESCRIPTORS = new PythonOptionsOptionDescriptors();

@CompilationFinal(dimensions = 1) private static final OptionKey<?>[] ENGINE_OPTION_KEYS;
Expand Down Expand Up @@ -541,6 +536,16 @@ public static boolean areOptionsCompatible(OptionValues first, OptionValues seco
return true;
}

public static void setUncachedInterpreterThreshold(PythonLanguage language, BytecodeNode bytecodeNode) {
if (language.getEngineOption(ForceUncachedInterpreter)) {
bytecodeNode.setUncachedThreshold(Integer.MIN_VALUE);
}
int threshold = language.getEngineOption(UncachedInterpreterThreshold);
if (threshold >= 0) {
bytecodeNode.setUncachedThreshold(threshold);
}
}

@Idempotent
public static int getAttributeAccessInlineCacheMaxDepth() {
CompilerAsserts.neverPartOfCompilation();
Expand Down
5 changes: 0 additions & 5 deletions mx.graalpython/mx_graalpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,6 @@ def github_ci_build_args():

def libpythonvm_build_args():
build_args = bytecode_dsl_build_args()

if limit := os.environ.get('GRAALPY_UncachedInterpreterLimit'):
mx.log(f"Uncached interpreter limit explicitly set to {limit}")
build_args += [f'-Dpython.UncachedInterpreterLimit={limit}']

if os.environ.get("GITHUB_CI"):
build_args += github_ci_build_args()

Expand Down
5 changes: 5 additions & 0 deletions mx.graalpython/mx_graalpython_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
CONFIGURATION_NATIVE_INTERPRETER_MULTI = "native-interpreter-multi"
CONFIGURATION_DEFAULT_MULTI_TIER = "default-multi-tier"
CONFIGURATION_NATIVE = "native"
CONFIGURATION_UNCACHED = "interpreter-uncached"
CONFIGURATION_NATIVE_MULTI = "native-multi"
CONFIGURATION_NATIVE_MULTI_TIER = "native-multi-tier"
CONFIGURATION_SANDBOXED = "sandboxed"
Expand Down Expand Up @@ -335,6 +336,9 @@ def extract_vm_info(self, args=None):
def run(self, *args, **kwargs):
code, out, dims = super().run(*args, **kwargs)
dims.update(self._dims)
is_uncached_config = self.config_name().startswith(CONFIGURATION_UNCACHED)
if ("forced uncached interpreter: True" not in out) == is_uncached_config:
mx.abort(f"ERROR: benchmark config '{CONFIGURATION_UNCACHED}' not consistent with what runtime reported.")
return code, out, dims

def get_extra_polyglot_args(self):
Expand Down Expand Up @@ -1084,6 +1088,7 @@ def add_graalpy_vm(name, *extra_polyglot_args):
add_graalpy_vm(CONFIGURATION_DEFAULT_MULTI_TIER, '--experimental-options', '--engine.MultiTier=true')
add_graalpy_vm(CONFIGURATION_SANDBOXED, *sandboxed_options)
add_graalpy_vm(CONFIGURATION_NATIVE)
add_graalpy_vm(CONFIGURATION_UNCACHED, '--experimental-options', '--engine.Compilation=false', '--python.ForceUncachedInterpreter=true')
add_graalpy_vm(CONFIGURATION_NATIVE_INTERPRETER, '--experimental-options', '--engine.Compilation=false')
add_graalpy_vm(CONFIGURATION_SANDBOXED_MULTI, '--experimental-options', '-multi-context', *sandboxed_options)
add_graalpy_vm(CONFIGURATION_NATIVE_MULTI, '--experimental-options', '-multi-context')
Expand Down
Loading