Search in sources :

Example 1 with HotMethodRecompilationEvent

use of org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent in project JikesRVM by JikesRVM.

the class MethodSampleOrganizer method thresholdReached.

@Override
void thresholdReached() {
    AOSLogging.logger.organizerThresholdReached();
    int numSamples = ((MethodListener) listener).getNumSamples();
    int[] samples = ((MethodListener) listener).getSamples();
    // (1) Update the global (cumulative) sample data
    Controller.methodSamples.update(samples, numSamples);
    // (2) Remove duplicates from samples buffer.
    // NOTE: This is a dirty trick and may be ill-advised.
    // Rather than copying the unique samples into a different buffer
    // we treat samples as if it was a scratch buffer.
    // NOTE: This is worse case O(numSamples^2) but we expect a
    // significant number of duplicates, so it's probably better than
    // the other obvious alternative (sorting samples).
    int uniqueIdx = 1;
    outer: for (int i = 1; i < numSamples; i++) {
        int cur = samples[i];
        for (int j = 0; j < uniqueIdx; j++) {
            if (cur == samples[j])
                continue outer;
        }
        samples[uniqueIdx++] = cur;
    }
    // then report it to the controller.
    for (int i = 0; i < uniqueIdx; i++) {
        int cmid = samples[i];
        double ns = Controller.methodSamples.getData(cmid);
        CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
        if (cm != null) {
            // not already obsoleted
            int compilerType = cm.getCompilerType();
            // compiled at filterOptLevel or higher.
            if (!(compilerType == CompiledMethod.TRAP || (compilerType == CompiledMethod.OPT && (((OptCompiledMethod) cm).getOptLevel() >= filterOptLevel)))) {
                HotMethodRecompilationEvent event = new HotMethodRecompilationEvent(cm, ns);
                Controller.controllerInputQueue.insert(ns, event);
                AOSLogging.logger.controllerNotifiedForHotness(cm, ns);
            }
        }
    }
}
Also used : HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) MethodListener(org.jikesrvm.adaptive.measurements.listeners.MethodListener) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 2 with HotMethodRecompilationEvent

use of org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent in project JikesRVM by JikesRVM.

the class MethodCountData method collectHotOptMethodsInternal.

/**
 * Recursive implementation of collectHotOptNMethods.
 * Exploit heap property.
 * Constraint: threshold has been converted into a count value by my caller!
 *
 * @param index count array index
 * @param collect vector used to collect output.
 * @param threshold hotness value above which the method is considered
 *                  to be hot. (0.0 to 1.0)
 * @param optLevel target opt level to look for.
 */
private void collectHotOptMethodsInternal(int index, List<HotMethodRecompilationEvent> collect, double threshold, int optLevel) {
    if (index < nextIndex) {
        if (counts[index] > threshold) {
            int cmid = cmids[index];
            CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
            if (cm == null) {
                // obsolete and deleted
                // free up this slot
                reset(cmid);
                // Visit new one in the slot
                collectHotOptMethodsInternal(index, collect, threshold, optLevel);
            } else {
                int compilerType = cm.getCompilerType();
                if (compilerType == CompiledMethod.OPT && ((OptCompiledMethod) cm).getOptLevel() == optLevel) {
                    double ns = counts[index];
                    collect.add(new HotMethodRecompilationEvent(cm, ns));
                }
                // Since I was hot enough, also consider my children.
                collectHotOptMethodsInternal(index * 2, collect, threshold, optLevel);
                collectHotOptMethodsInternal(index * 2 + 1, collect, threshold, optLevel);
            }
        }
    }
}
Also used : OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod) HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 3 with HotMethodRecompilationEvent

use of org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent in project JikesRVM by JikesRVM.

the class MethodCountData method collectHotMethods.

/**
 * Collect the hot methods that have been compiled at the given opt level.
 *
 * @param optLevel  target opt level
 * @param threshold hotness value above which the method is considered to
 *                  be hot. (0.0 to 1.0)
 * @return a MethodCountSet containing an
 *            array of compiled methods and an array of their counts.
 */
public synchronized MethodCountSet collectHotMethods(int optLevel, double threshold) {
    if (DEBUG)
        validityCheck();
    ArrayList<HotMethodRecompilationEvent> collect = new ArrayList<HotMethodRecompilationEvent>();
    collectHotOptMethodsInternal(1, collect, hotnessToCounts(threshold), optLevel);
    // now package the data into the form the caller expects.
    int numHotMethods = collect.size();
    double[] numCounts = new double[numHotMethods];
    CompiledMethod[] hotMethods = new CompiledMethod[numHotMethods];
    for (int i = 0; i < numHotMethods; i++) {
        HotMethodEvent event = collect.get(i);
        hotMethods[i] = event.getCompiledMethod();
        numCounts[i] = event.getNumSamples();
    }
    return new MethodCountSet(hotMethods, numCounts);
}
Also used : HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) HotMethodEvent(org.jikesrvm.adaptive.controller.HotMethodEvent) ArrayList(java.util.ArrayList) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Example 4 with HotMethodRecompilationEvent

use of org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent in project JikesRVM by JikesRVM.

the class MethodCountData method insertHotMethodsInternal.

/**
 * Recursive implementation of insertHotMethods. Exploit heap property.
 * Note threshold has been converted into a count value by my caller!
 *
 * @param index count array index
 * @param filterOptLevel filter out all methods already compiled at
 *                       this opt level (or higher)
 * @param threshold hotness value above which the method is considered
 *                  to be hot. (0.0 to 1.0)
 */
private void insertHotMethodsInternal(int index, int filterOptLevel, double threshold) {
    if (index < nextIndex) {
        if (counts[index] > threshold) {
            int cmid = cmids[index];
            CompiledMethod cm = CompiledMethods.getCompiledMethod(cmid);
            if (cm == null) {
                // obsolete and deleted
                // free up this slot
                reset(cmid);
                // Visit new one in the slot
                insertHotMethodsInternal(index, filterOptLevel, threshold);
            } else {
                int compilerType = cm.getCompilerType();
                // opt compiled at filterOptLevel or higher.
                if (!(compilerType == CompiledMethod.TRAP || (compilerType == CompiledMethod.OPT && (((OptCompiledMethod) cm).getOptLevel() >= filterOptLevel)))) {
                    double ns = counts[index];
                    HotMethodRecompilationEvent event = new HotMethodRecompilationEvent(cm, ns);
                    Controller.controllerInputQueue.insert(ns, event);
                    AOSLogging.logger.controllerNotifiedForHotness(cm, ns);
                }
                // Since I was hot enough, also consider my children.
                insertHotMethodsInternal(index * 2, filterOptLevel, threshold);
                insertHotMethodsInternal(index * 2 + 1, filterOptLevel, threshold);
            }
        }
    }
}
Also used : HotMethodRecompilationEvent(org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent) CompiledMethod(org.jikesrvm.compilers.common.CompiledMethod) OptCompiledMethod(org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)

Aggregations

HotMethodRecompilationEvent (org.jikesrvm.adaptive.controller.HotMethodRecompilationEvent)4 CompiledMethod (org.jikesrvm.compilers.common.CompiledMethod)4 OptCompiledMethod (org.jikesrvm.compilers.opt.runtimesupport.OptCompiledMethod)4 ArrayList (java.util.ArrayList)1 HotMethodEvent (org.jikesrvm.adaptive.controller.HotMethodEvent)1 MethodListener (org.jikesrvm.adaptive.measurements.listeners.MethodListener)1