Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed up old profiling code
* Turned off inlining for now so we can play with profiling
  independently.
  • Loading branch information
subbuss committed Nov 17, 2014
1 parent 658390a commit 06dcfae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Expand Up @@ -561,12 +561,13 @@ private static IRubyObject interpret(ThreadContext context, IRubyObject self,
Object exception = null;
DynamicScope currDynScope = context.getCurrentScope();
StaticScope currScope = interpreterContext.getStaticScope();
IRScope scope = currScope.getIRScope();
boolean acceptsKeywordArgument = interpreterContext.receivesKeywordArguments();

// Init profiling this scope
boolean debug = IRRuntimeHelpers.isDebug();
boolean profile = IRRuntimeHelpers.inProfileMode();
//Integer scopeVersion = profile ? Profiler.initProfiling(scope) : 0;
boolean acceptsKeywordArgument = interpreterContext.receivesKeywordArguments();
Integer scopeVersion = profile ? Profiler.initProfiling(scope) : 0;

// Enter the looooop!
while (ipc < n) {
Expand All @@ -593,7 +594,7 @@ private static IRubyObject interpret(ThreadContext context, IRubyObject self,
receiveArg(context, instr, operation, args, acceptsKeywordArgument, currDynScope, temp, exception, block);
break;
case CALL_OP:
//if (profile) Profiler.updateCallSite(instr, scope, scopeVersion);
if (profile) Profiler.updateCallSite(instr, scope, scopeVersion);
processCall(context, instr, operation, currDynScope, currScope, temp, self);
break;
case RET_OP:
Expand Down
22 changes: 13 additions & 9 deletions core/src/main/java/org/jruby/ir/interpreter/Profiler.java
Expand Up @@ -21,7 +21,7 @@ private static class IRCallSite {
long count;
InterpretedIRMethod tgtM;

public IRCallSite() { }
public IRCallSite() {}

public IRCallSite(IRCallSite cs) {
this.s = cs.s;
Expand Down Expand Up @@ -86,7 +86,7 @@ private static void analyzeProfile() {
IRCallSite cs = csp.cs;

if (cs.v != scopeVersionMap.get(cs.s).intValue()) {
// System.out.println("Skipping callsite: <" + cs.s + "," + cs.v + "> with compiled version: " + scopeVersionMap.get(cs.s));
System.out.println("Skipping callsite: <" + cs.s + "," + cs.v + "> with compiled version: " + scopeVersionMap.get(cs.s));
continue;
}

Expand Down Expand Up @@ -149,8 +149,8 @@ public int compare(IRCallSite a, IRCallSite b) {
// This check is arbitrary
if (i == 100 || freq > 99.0) break;

// System.out.println("Considering: " + ircs.call + " with id: " + ircs.call.callSiteId +
// " in scope " + ircs.s + " with count " + ircs.count + "; contrib " + contrib + "; freq: " + freq);
System.out.println("Considering: " + ircs.call + " with id: " + ircs.call.callSiteId +
" in scope " + ircs.s + " with count " + ircs.count + "; contrib " + contrib + "; freq: " + freq);

// Now inline here!
CallBase call = ircs.call;
Expand All @@ -166,8 +166,8 @@ public int compare(IRCallSite a, IRCallSite b) {
// Dont inline large methods -- 500 is arbitrary
// Can be null if a previously inlined method hasn't been rebuilt
if ((instrs == null) || instrs.length > 500) {
// if (instrs == null) System.out.println("no instrs!");
// else System.out.println("large method with " + instrs.length + " instrs. skipping!");
if (instrs == null) System.out.println("no instrs!");
else System.out.println("large method with " + instrs.length + " instrs. skipping!");
continue;
}

Expand All @@ -179,7 +179,7 @@ public int compare(IRCallSite a, IRCallSite b) {
Operand clArg = call.getClosureArg(null);
inlineCall = (clArg instanceof WrappedIRClosure) && (((WrappedIRClosure)clArg).getClosure() == hc);
}

/*
if (inlineCall) {
noInlining = false;
long start = new java.util.Date().getTime();
Expand All @@ -194,6 +194,7 @@ public int compare(IRCallSite a, IRCallSite b) {
} else {
//System.out.println("--no inlining--");
}
*/
}

for (IRScope x: inlinedScopes) {
Expand Down Expand Up @@ -277,6 +278,8 @@ public int compare(IRScope a, IRScope b) {
}

public static Integer initProfiling(IRScope scope) {
if (scope == null) return null;

/* SSS: Not being used currently
tpCount = scopeThreadPollCounts.get(scope);
if (tpCount == null) {
Expand Down Expand Up @@ -311,6 +314,8 @@ public static Integer initProfiling(IRScope scope) {
}

public static void updateCallSite(Instr instr, IRScope scope, Integer scopeVersion) {
if (scope == null) return;

if (instr instanceof CallBase) {
callerSite.s = scope;
callerSite.v = scopeVersion;
Expand All @@ -319,8 +324,7 @@ public static void updateCallSite(Instr instr, IRScope scope, Integer scopeVersi
}

public static void clockTick() {
// SSS: Not being used currently
// tpCount.count++;
// tpCount.count++; // SSS: Not being used currently
globalThreadPollCount++;

// 20K is arbitrary
Expand Down

0 comments on commit 06dcfae

Please sign in to comment.