Skip to content

Commit

Permalink
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -246,6 +246,7 @@ public class Options {
public static final Option<Integer> TRUFFLE_PACK_CACHE = integer(TRUFFLE, "truffle.pack.cache", TRUFFLE_DEFAULT_CACHE.load(), "Array#pack cache size");
public static final Option<Integer> TRUFFLE_UNPACK_CACHE = integer(TRUFFLE, "truffle.unpack.cache", TRUFFLE_DEFAULT_CACHE.load(), "String#unpack cache size");
public static final Option<Integer> TRUFFLE_EVAL_CACHE = integer(TRUFFLE, "truffle.eval.cache", TRUFFLE_DEFAULT_CACHE.load(), "eval lookup cache size");
public static final Option<Integer> TRUFFLE_CLASS_CACHE = integer(TRUFFLE, "truffle.class.cache", TRUFFLE_DEFAULT_CACHE.load(), ".class and .metaclass cache size");

This comment has been minimized.

Copy link
@eregon

eregon Feb 24, 2016

Member

This cache should be smaller because the generic case is only 3 reads instead of 1 + compare.
I think monomorphic makes sense here because the conditions are likely more expensive than the 2 reads.

This comment has been minimized.

Copy link
@chrisseaton

chrisseaton Feb 24, 2016

Author Contributor

I don't think it's important to tune this option now. Any argument either of us made would really just be guessing. All these numbers are arbitrary and what we need to do is run some serious Ruby applications and do some machine learning to find the best combination for startup, for peak, and a balance between the two.

public static final Option<Integer> TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE = integer(TRUFFLE, "truffle.encoding_compatible_query.cache", TRUFFLE_DEFAULT_CACHE.load(), "Encoding.compatible? cache size");

public static final Option<Boolean> TRUFFLE_CLONE_DEFAULT = bool(TRUFFLE, "truffle.clone.default", true, "Default option for cloning.");
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ public class Options {
public final int PACK_CACHE = TRUFFLE_PACK_CACHE.load();
public final int UNPACK_CACHE = TRUFFLE_UNPACK_CACHE.load();
public final int EVAL_CACHE = TRUFFLE_EVAL_CACHE.load();
public final int CLASS_CACHE = TRUFFLE_CLASS_CACHE.load();
public final int ENCODING_COMPATIBILE_QUERY_CACHE = TRUFFLE_ENCODING_COMPATIBLE_QUERY_CACHE.load();

// Cloning and inlining
Original file line number Diff line number Diff line change
@@ -55,8 +55,8 @@ protected DynamicObject metaClassDouble(double value) {

@Specialization(guards = "object.getShape() == cachedShape",
assumptions = "cachedShape.getValidAssumption()",
limit = "1")
protected DynamicObject cachedMetaClass(DynamicObject object,
limit = "getCacheLimit()")
protected DynamicObject metaClassCached(DynamicObject object,
@Cached("object.getShape()") Shape cachedShape,
@Cached("getMetaClass(cachedShape)") DynamicObject metaClass) {
return metaClass;
@@ -67,13 +67,17 @@ protected DynamicObject updateShapeAndMetaClass(DynamicObject object) {
return executeMetaClass(object);
}

@Specialization(contains = { "cachedMetaClass", "updateShapeAndMetaClass" })
protected DynamicObject metaClass(DynamicObject object) {
@Specialization(contains = { "metaClassCached", "updateShapeAndMetaClass" })
protected DynamicObject metaClassUncached(DynamicObject object) {
return Layouts.BASIC_OBJECT.getMetaClass(object);
}

protected static DynamicObject getMetaClass(Shape shape) {
return Layouts.BASIC_OBJECT.getMetaClass(shape.getObjectType());
}

protected int getCacheLimit() {
return getContext().getOptions().CLASS_CACHE;
}

}

0 comments on commit 1b884f8

Please sign in to comment.