Search in sources :

Example 1 with MaxThroughputSummary

use of alluxio.stress.master.MaxThroughputSummary in project alluxio by Alluxio.

the class MaxThroughput method runSuite.

@Override
public MaxThroughputSummary runSuite(String[] args) throws Exception {
    try (JobMasterClient client = JobMasterClient.Factory.create(JobMasterClientContext.newBuilder(ClientContext.create(new InstancedConfiguration(ConfigurationUtils.defaults()))).build())) {
        mNumWorkers = client.getAllWorkerHealth().size();
    }
    if (mNumWorkers <= 0) {
        throw new IllegalStateException("No workers available for testing!");
    }
    MaxThroughputSummary summary = new MaxThroughputSummary();
    summary.setParameters(mParameters);
    List<String> baseArgs = new ArrayList<>(Arrays.asList(args));
    if (!mParameters.mSkipPrepare) {
        prepareBeforeAllTests(baseArgs);
    }
    int lower = 0;
    int upper = Integer.MAX_VALUE;
    // use the input target throughput as the starting point
    int next = mParameters.mTargetThroughput;
    int best = 0;
    while (true) {
        int perWorkerThroughput = next / mNumWorkers;
        int requestedThroughput = perWorkerThroughput * mNumWorkers;
        if (perWorkerThroughput == 0) {
            // Cannot run with a target of 0
            break;
        }
        List<String> newArgs = new ArrayList<>(baseArgs);
        updateArgValue(newArgs, "--target-throughput", Integer.toString(perWorkerThroughput));
        long runSec = (FormatUtils.parseTimeSize(mParameters.mDuration) + FormatUtils.parseTimeSize(mParameters.mWarmup)) / 1000;
        // the expected number of paths required for the test to complete successfully
        long requiredCount = next * runSec;
        MasterBenchSummary mbr = runSingleTest(requiredCount, newArgs);
        int current = next;
        final float actualThroughput = mbr.getThroughput();
        if ((actualThroughput > requestedThroughput) || ((requestedThroughput - actualThroughput) / (float) requestedThroughput) < 0.02) {
            // the throughput was achieved. increase.
            summary.addPassedRun(current, mbr);
            best = current;
            // update the lower bound.
            lower = current;
            if (upper == Integer.MAX_VALUE) {
                next *= 2;
            } else {
                next = (next + upper) / 2;
            }
        } else {
            // Failed to achieve the target throughput. update the upper bound.
            summary.addFailedRun(current, mbr);
            upper = current;
            // throughput was not achieved. decrease.
            next = (lower + next) / 2;
        }
        LOG.info("target: " + requestedThroughput + " actual: " + actualThroughput + " [" + lower + " " + next + " " + upper + "]");
        for (String error : mbr.collectErrorsFromAllNodes()) {
            LOG.error("{}", error);
        }
        if (Math.abs(current - next) / (float) current <= 0.02) {
            break;
        }
    }
    LOG.info("max throughput: " + best);
    summary.setEndTimeMs(CommonUtils.getCurrentMs());
    summary.setMaxThroughput(best);
    return summary;
}
Also used : JobMasterClient(alluxio.client.job.JobMasterClient) InstancedConfiguration(alluxio.conf.InstancedConfiguration) ArrayList(java.util.ArrayList) MasterBenchSummary(alluxio.stress.master.MasterBenchSummary) MaxThroughputSummary(alluxio.stress.master.MaxThroughputSummary)

Aggregations

JobMasterClient (alluxio.client.job.JobMasterClient)1 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 MasterBenchSummary (alluxio.stress.master.MasterBenchSummary)1 MaxThroughputSummary (alluxio.stress.master.MaxThroughputSummary)1 ArrayList (java.util.ArrayList)1