Skip to content

Commit 5f847d6

Browse files
committed
[GR-70907] Remove allocation reporting.
PullRequest: graalpython/4071
2 parents c65925b + 22bc716 commit 5f847d6

File tree

120 files changed

+682
-849
lines changed

Some content is hidden

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

120 files changed

+682
-849
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ language runtime. The main focus is on user-observable behavior of the engine.
55

66
## Version 25.1.0
77
* Intern string literals in source files
8+
* Allocation reporting via Truffle has been removed. Python object sizes were never reported correctly, so the data was misleading and there was a non-neglible overhead for object allocations even when reporting was inactive.
89

910
## Version 25.0.1
1011
* Allow users to keep going on unsupported JDK/OS/ARCH combinations at their own risk by opting out of early failure using `-Dtruffle.UseFallbackRuntime=true`, `-Dpolyglot.engine.userResourceCache=/set/to/a/writeable/dir`, `-Dpolyglot.engine.allowUnsupportedPlatform=true`, and `-Dpolyglot.python.UnsupportedPlatformEmulates=[linux|macos|windows]` and `-Dorg.graalvm.python.resources.exclude=native.files`.

graalpython/com.oracle.graal.python.pegparser.generator/asdl/asdl_java.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def visit_enum(self, c: model.Enum, emitter: java_file.Emitter):
225225
emitter.println()
226226
emitter.println(f'// {c.name.java}.{m.java}')
227227
self.emit_make_type(emitter, m, c.name, (), (), m.python)
228-
emitter.println(f'{m.singleton_field} = factory.createSingleton({m.cls_field});')
228+
emitter.println(f'{m.singleton_field} = AstTypeFactory.createSingleton({m.cls_field});')
229229

230230
@staticmethod
231231
def emit_make_type(emitter: java_file.Emitter, name: model.Name, base_class: Optional[model.Name],

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/runtime/PythonModuleTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void tearDown() {
9292

9393
@Test
9494
public void pythonModuleTest() {
95-
PythonModule module = PFactory.createPythonModule(context.getLanguage(), tsLiteral("testModule"));
95+
PythonModule module = PFactory.createPythonModule(tsLiteral("testModule"));
9696
assertEquals("testModule", module.getAttribute(T___NAME__).toString());
9797
assertEquals("None", module.getAttribute(T___DOC__).toString());
9898
assertEquals("None", module.getAttribute(T___PACKAGE__).toString());

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@
129129
import com.oracle.truffle.api.dsl.Idempotent;
130130
import com.oracle.truffle.api.exception.AbstractTruffleException;
131131
import com.oracle.truffle.api.frame.VirtualFrame;
132-
import com.oracle.truffle.api.instrumentation.AllocationReporter;
133132
import com.oracle.truffle.api.instrumentation.ProvidedTags;
134133
import com.oracle.truffle.api.instrumentation.StandardTags;
135134
import com.oracle.truffle.api.interop.InteropLibrary;
@@ -396,7 +395,6 @@ public boolean isSingleContext() {
396395

397396
@CompilationFinal(dimensions = 1) private volatile Object[] engineOptionsStorage;
398397
@CompilationFinal private volatile OptionValues engineOptions;
399-
@CompilationFinal private AllocationReporter allocationReporter;
400398

401399
/** For fast access to the PythonThreadState object by the owning thread. */
402400
private final ContextThreadLocal<PythonThreadState> threadState = locals.createContextThreadLocal(PythonContext.PythonThreadState::new);
@@ -491,11 +489,6 @@ public <T> T getEngineOption(OptionKey<T> key) {
491489
}
492490
}
493491

494-
public AllocationReporter getAllocationReporter() {
495-
assert allocationReporter != null;
496-
return allocationReporter;
497-
}
498-
499492
@Override
500493
protected OptionDescriptors getOptionDescriptors() {
501494
return PythonOptions.DESCRIPTORS;
@@ -504,12 +497,6 @@ protected OptionDescriptors getOptionDescriptors() {
504497
@Override
505498
protected void initializeContext(PythonContext context) {
506499
if (!isLanguageInitialized) {
507-
if (allocationReporter == null) {
508-
allocationReporter = context.getEnv().lookup(AllocationReporter.class);
509-
} else {
510-
// GR-61960
511-
// assert allocationReporter == env.lookup(AllocationReporter.class);
512-
}
513500
initializeLanguage();
514501
}
515502
if (PythonOS.isUnsupported() && context.getEnv().isNativeAccessAllowed()) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,8 +1230,8 @@ private void initializeTypes() {
12301230
// now initialize well-known objects
12311231
PythonBuiltinClassType booleanType = PythonBuiltinClassType.Boolean;
12321232
Shape booleanShape = booleanType.getInstanceShape(getLanguage());
1233-
pyTrue = PFactory.createInt(getLanguage(), booleanType, booleanShape, BigInteger.ONE);
1234-
pyFalse = PFactory.createInt(getLanguage(), booleanType, booleanShape, BigInteger.ZERO);
1233+
pyTrue = PFactory.createInt(booleanType, booleanShape, BigInteger.ONE);
1234+
pyFalse = PFactory.createInt(booleanType, booleanShape, BigInteger.ZERO);
12351235
pyNaN = PFactory.createFloat(getLanguage(), Double.NaN);
12361236
}
12371237

@@ -1284,7 +1284,7 @@ private void addBuiltinModule(TruffleString name, PythonModule module) {
12841284
private PythonModule createModule(TruffleString name, PythonBuiltins moduleBuiltins) {
12851285
PythonModule mod = builtinModules.get(name);
12861286
if (mod == null) {
1287-
mod = PFactory.createPythonModule(getLanguage(), name);
1287+
mod = PFactory.createPythonModule(name);
12881288
if (moduleBuiltins != null) {
12891289
mod.setBuiltins(moduleBuiltins);
12901290
}
@@ -1321,7 +1321,7 @@ private void loadFile(TruffleString s, TruffleString prefix) {
13211321
PythonModule mod = lookupBuiltinModule(s);
13221322
if (mod == null) {
13231323
// use an anonymous module for the side-effects
1324-
mod = PFactory.createPythonModule(getLanguage(), T___ANONYMOUS__);
1324+
mod = PFactory.createPythonModule(T___ANONYMOUS__);
13251325
}
13261326
loadFile(s, prefix, mod);
13271327
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ArrayModuleBuiltins.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.nio.ByteOrder;
3636
import java.util.List;
3737

38-
import com.oracle.graal.python.PythonLanguage;
3938
import com.oracle.graal.python.annotations.ArgumentClinic;
4039
import com.oracle.graal.python.annotations.Builtin;
4140
import com.oracle.graal.python.builtins.CoreFunctions;
@@ -151,11 +150,11 @@ private static Object doReconstruct(VirtualFrame frame, Node inliningTarget, Obj
151150
if (machineFormat != null) {
152151
PArray array;
153152
if (machineFormat == MachineFormat.forFormat(format)) {
154-
array = PFactory.createArray(PythonLanguage.get(inliningTarget), arrayType, getInstanceShape.execute(arrayType), typeCode, machineFormat.format);
153+
array = PFactory.createArray(arrayType, getInstanceShape.execute(arrayType), typeCode, machineFormat.format);
155154
fromBytesNode.executeWithoutClinic(frame, array, bytes);
156155
} else {
157156
TruffleString newTypeCode = machineFormat.format == format ? typeCode : machineFormat.format.baseTypeCode;
158-
array = PFactory.createArray(PythonLanguage.get(inliningTarget), arrayType, getInstanceShape.execute(arrayType), newTypeCode, machineFormat.format);
157+
array = PFactory.createArray(arrayType, getInstanceShape.execute(arrayType), newTypeCode, machineFormat.format);
159158
if (machineFormat.unicodeEncoding != null) {
160159
Object decoded = callDecode.execute(frame, inliningTarget, bytes, T_DECODE, machineFormat.unicodeEncoding);
161160
fromUnicodeNode.execute(frame, array, decoded);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/CodecsTruffleModuleBuiltins.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,30 +186,29 @@ static PTuple codecsInfo(PythonModule self, TruffleString encoding, PythonContex
186186
initCodecClasses(self, codecsModule, context);
187187
}
188188

189-
PythonLanguage language = context.getLanguage();
190189
// encode/decode methods for codecs.CodecInfo
191-
PythonObject truffleCodec = createPythonObject(language, codecsTruffleBuiltins.truffleCodecClass);
190+
PythonObject truffleCodec = createPythonObject(codecsTruffleBuiltins.truffleCodecClass);
192191
truffleCodec.setAttribute(T_ATTR_ENCODING, encoding);
193192
Object encodeMethod = PyObjectGetAttr.executeUncached(truffleCodec, T_ENCODE);
194193
Object decodeMethod = PyObjectGetAttr.executeUncached(truffleCodec, T_DECODE);
195194

196195
// incrementalencoder factory function for codecs.CodecInfo
197-
PythonObject tie = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass);
196+
PythonObject tie = createPythonObject(codecsTruffleBuiltins.applyEncodingClass);
198197
tie.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleIncrementalEncoderClass);
199198
tie.setAttribute(T_ATTR_ENCODING, encoding);
200199

201200
// incrementaldecoder factory function for codecs.CodecInfo
202-
PythonObject tid = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass);
201+
PythonObject tid = createPythonObject(codecsTruffleBuiltins.applyEncodingClass);
203202
tid.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleIncrementalDecoderClass);
204203
tid.setAttribute(T_ATTR_ENCODING, encoding);
205204

206205
// streamwriter factory function for codecs.CodecInfo
207-
PythonObject sr = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass);
206+
PythonObject sr = createPythonObject(codecsTruffleBuiltins.applyEncodingClass);
208207
sr.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleStreamReaderClass);
209208
sr.setAttribute(T_ATTR_ENCODING, encoding);
210209

211210
// streamreader factory function for codecs.CodecInfo
212-
PythonObject sw = createPythonObject(language, codecsTruffleBuiltins.applyEncodingClass);
211+
PythonObject sw = createPythonObject(codecsTruffleBuiltins.applyEncodingClass);
213212
sw.setAttribute(T_ATTR_FN, codecsTruffleBuiltins.truffleStreamWriterClass);
214213
sw.setAttribute(T_ATTR_ENCODING, encoding);
215214

@@ -218,8 +217,8 @@ static PTuple codecsInfo(PythonModule self, TruffleString encoding, PythonContex
218217
return (PTuple) CallNode.getUncached().execute(null, codecInfoClass, new Object[]{}, createCodecInfoArgs(encoding, encodeMethod, decodeMethod, tie, tid, sr, sw));
219218
}
220219

221-
private static PythonObject createPythonObject(PythonLanguage language, PythonClass cls) {
222-
return PFactory.createPythonObject(language, cls, cls.getInstanceShape());
220+
private static PythonObject createPythonObject(PythonClass cls) {
221+
return PFactory.createPythonObject(cls, cls.getInstanceShape());
223222
}
224223

225224
private static PKeyword[] createCodecInfoArgs(TruffleString encoding, Object encodeMethod, Object decodeMethod, PythonObject tie, PythonObject tid, PythonObject sr, PythonObject sw) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ImpModuleBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ public static PythonModule importFrozenModuleObject(Python3Core core, TruffleStr
601601
}
602602

603603
RootCallTarget callTarget = createCallTarget(core.getContext(), info);
604-
PythonModule module = globals == null ? PFactory.createPythonModule(core.getLanguage(), name) : globals;
604+
PythonModule module = globals == null ? PFactory.createPythonModule(name) : globals;
605605

606606
if (info.isPackage) {
607607
/* Set __path__ to the empty list */

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ast/AstBuiltins.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ public abstract static class AstNode extends PythonVarargsBuiltinNode {
108108

109109
@Specialization
110110
static PythonObject generic(Object cls, @SuppressWarnings("unused") Object[] varargs, @SuppressWarnings("unused") PKeyword[] kwargs,
111-
@Bind PythonLanguage language,
112111
@Cached TypeNodes.GetInstanceShape getInstanceShape) {
113-
return PFactory.createPythonObject(language, cls, getInstanceShape.execute(cls));
112+
return PFactory.createPythonObject(cls, getInstanceShape.execute(cls));
114113
}
115114
}
116115

0 commit comments

Comments
 (0)