-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
[Truffle] Implement objspace. #3321
Conversation
@@ -55,6 +58,10 @@ public void clearFinalizers() { | |||
private final ReferenceQueue<DynamicObject> finalizerQueue = new ReferenceQueue<>(); | |||
private DynamicObject finalizerThread; | |||
|
|||
private final CyclicAssumption tracingAssumption = new CyclicAssumption("objspec-tracing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objspace-tracing I suppose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
count_nodes_tree Truffle::Primitive.ast(method), nodes | ||
end | ||
|
||
private :count_nodes_method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For style, usually the private
follows the end
or then the scope/frame-level private
is used only once (better in this case I think).
A third alternative from Ruby 2.2 is private def count_nodes_method(method, nodes)
but might be strange for indent reasons.
Looks great! And node/allocation stats are always useful. |
I removed the short circuit as it significantly simplifies the logic of visiting the object graph. I think that trade-off is valid for an operation we don't expect many people to be using. I found a lot of bugs when I actually started to write |
Conflicts: truffle/src/main/java/org/jruby/truffle/nodes/core/ObjectSpaceNodes.java truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
@@ -55,6 +58,10 @@ public void clearFinalizers() { | |||
private final ReferenceQueue<DynamicObject> finalizerQueue = new ReferenceQueue<>(); | |||
private DynamicObject finalizerThread; | |||
|
|||
private final CyclicAssumption tracingAssumption = new CyclicAssumption("objspace-tracing"); | |||
private int tracingAssumptionActivations = 0; | |||
private boolean tracingPaused = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thread-safety is a problem here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably ThreadLocal<Boolean>
would work, but of course there is some overhead.
And AtomicInteger for tracingAssumptionActivations
.
…isn't implemented.
All the MRI tests pass apart from nine. |
} | ||
|
||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unused.
@@ -55,6 +60,11 @@ public void clearFinalizers() { | |||
private final ReferenceQueue<DynamicObject> finalizerQueue = new ReferenceQueue<>(); | |||
private DynamicObject finalizerThread; | |||
|
|||
private final CyclicAssumption tracingAssumption = new CyclicAssumption("objspace-tracing"); | |||
@CompilerDirectives.CompilationFinal private boolean isTracing = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is clearer, thanks!
Looks good, Travis overflows on 2 MRI test though. |
Conflicts: truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
[Truffle] Implement objspace.
Not massively useful I'll admit, but we can actually implement most of the methods here with something useful. If someone has a tool that uses
objspace
I would imagine it would display some useful stuff.In some cases like allocation tracing we can actually implement that without problem.
In some other cases I've translated features to Truffle. For example
#count_nodes
normally reports MRI AST node names, but I'm reporting Truffle node names, which is actually quite an interesting thing to see.@eregon please review