Skip to content
Permalink
Browse files
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 06dcfae12acfa611528051564ab179b7f279f36a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
@@ -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) {
@@ -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:
@@ -21,7 +21,7 @@ private static class IRCallSite {
long count;
InterpretedIRMethod tgtM;

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

public IRCallSite(IRCallSite cs) {
this.s = cs.s;
@@ -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;
}

@@ -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;
@@ -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;
}

@@ -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();
@@ -194,6 +194,7 @@ public int compare(IRCallSite a, IRCallSite b) {
} else {
//System.out.println("--no inlining--");
}
*/
}

for (IRScope x: inlinedScopes) {
@@ -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) {
@@ -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;
@@ -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

0 comments on commit 06dcfae

Please sign in to comment.