示例#1
0
def test_numa(args):
    """Test how NUMA architecture affects the filebench performance.
    """
    CPU_CONFS = ['0-23', '0-11,24-35', '0-5,12-17,24-29,36-41',
                 '0-2,6-8,12-14,18-20,24-26,30-32,36-38,42-44']
    ndisks = args.disks
    ndirs = args.dirs
    nproc = 48

    # Prepare output disk
    check_point = create_checkpoint('numa_checkpoint.log', 'filebench_numa')
    test_conf = {
        'test': 'numa',
        'filesystems': args.formats,
        'workloads': args.workloads,
        'iteration': args.iteration,
        'ndisks': ndisks,
        'ndirs': ndirs,
        'mount_options': 'noatime,nodirtime',
    }
    mfsbase.dump_configure(test_conf,
                           os.path.join(check_point.outdir, 'testmeta.txt'))

    steps = 0
    for fs in args.formats.split(','):
        for wl in args.workloads.split(','):
            for cpus in CPU_CONFS:
                set_cpus.set_cpus(cpus)
                for i in range(args.iteration):
                    steps += 1
                    if check_point.should_skip(steps):
                        continue
                    check_point.start()
                    output_prefix = '{}/numa_{}_{}_{}_{}_{}_{}'.format(
                        check_point.outdir, fs, wl, ndisks, ndirs, cpus, i)
                    print('Run NUMA test on CPUs {} for iteration {}'
                          .format(cpus, i))
                    retry = args.retry
                    while retry:
                        prepare_disks('ramdisks', ndisks, ndirs, fs=fs,
                                      no_journal=args.no_journal)
                        if run_filebench(wl, ndisks=ndisks, ndirs=ndirs,
                                         nprocs=nproc,
                                         threads=1, output=output_prefix,
                                         events=args.events,
                                         vmlinux=args.vmlinux,
                                         kallsyms=args.kallsyms,
                                         no_profile=args.no_profile):
                            break
                        print('Failed to execute run_filebench')
                        retry -= 1
                    if not retry:
                        set_cpus.reset()
                        return False
                    check_point.done()
            set_cpus.reset()
    return True
示例#2
0
def run_filebench(workload, **kwargs):
    """Run filebench.
    """
    ndisks = kwargs.get('ndisks', 4)
    ndirs = kwargs.get('ndirs', 1)
    basedir = kwargs.get('basedir', 'ramdisks')
    cpus = kwargs.get('cpus', '')
    nprocs = kwargs.get('nprocs', 1)
    nthreads = kwargs.get('nthreads', 1)
    output = kwargs.get('output', 'filebench')
    no_profile = kwargs.get('no_profile', False)
    affinity = kwargs.get('affinity', False)

    if cpus:
        set_cpus.set_cpus(cpus)

    lockstat = None
    procstat = None
    perf = None
    if not no_profile:
        lockstat = mfsbase.LockstatProfiler()
        procstat = mfsbase.ProcStatProfiler()
        perf = mfsbase.PerfProfiler(perf=PERF, **kwargs)
    else:
        lockstat = mfsbase.NonProfiler()
        procstat = mfsbase.NonProfiler()
        perf = mfsbase.NonProfiler()

    lockstat.start()
    procstat.start()

    result_file = output + '_results.txt'
    cmd = '{} run -w {} --disks {} --dirs {} -b {} -p {} -t {} -o {}' \
          .format(__file__, workload, ndisks, ndirs, basedir, nprocs, nthreads,
                  result_file)
    if affinity:
        cmd += ' --affinity'
    print(cmd)

    perf.start(cmd)
    procstat.stop()
    lockstat.stop()

    # Move PerfProfile.stop() to the last because it generates hunders of MBs
    # logs, which has significant impact to procstat and lockstat accuracy.
    perf.stop()

    if cpus:
        set_cpus.reset()

    procstat.dump(output + '_cpustat.txt')
    lockstat.dump(output + '_lockstat.txt')
    perf.dump(output + '_perf.txt')

    osutil.umount_all('ramdisks')
    return True
示例#3
0
def test_cpu_scale(args):
    """Run benchmark with different active CPUs.
    """
    ndisks = 1
    ndirs = 1
    no_journal = args.no_journal

    check_point = checkpoint.Checkpoint('cpu_checkpoint.log')
    output_dir = ''
    if check_point.outdir:
        output_dir = check_point.outdir
    else:
        now = datetime.now()
        output_dir = 'filebench_cpuscale_' + now.strftime('%Y_%m_%d_%H_%M')
        if os.path.exists(output_dir):
            shutil.rmtree(output_dir)
        os.makedirs(output_dir)
        check_point.set_outdir(output_dir)

    test_conf = {
        'test': 'cpu_scale',
        'filesystems': args.formats,
        'workloads': args.workloads,
        'iteration': args.iteration,
        'processes': str(list(range(4, 96, 12))),
        'ndisks': ndisks,
        'ndirs': ndirs,
        'mount_options': 'noatime,nodirtime',
    }
    mfsbase.dump_configure(test_conf, os.path.join(output_dir, 'testmeta.txt'))

    steps = 0
    nproc = args.process
    for fs in args.formats.split(','):
        for wl in args.workloads.split(','):
            for ncpus in map(int, args.cpus):
                cpus = "0-{}".format(ncpus - 1)
                print('CPU scale test: cpus: {}, fs: {}, workload: {}'.format(
                    cpus, fs, wl))
                set_cpus.set_cpus(cpus)
                for i in range(args.iteration):
                    steps += 1
                    if check_point.should_skip(steps):
                        continue
                    check_point.start()
                    retry = args.retry
                    print('Run CPU scalability test')
                    output_prefix = '{}/cpuscale_{}_{}_{}_{}_{}_{}'.format(
                        output_dir, fs, wl, ndisks, ndirs, ncpus, i)
                    while retry:
                        prepare_disks('ramdisks', ndisks, ndirs, fs=fs,
                                      no_journal=no_journal)
                        if not run_filebench(wl, ndisks=ndisks, ndirs=ndirs,
                                             nprocs=nproc,
                                             threads=1, output=output_prefix,
                                             events=args.events,
                                             vmlinux=args.vmlinux,
                                             kallsyms=args.kallsyms,
                                             no_profile=args.no_profile):
                            # set_cpus.reset()
                            print('Failed to execute run_filebench')
                            retry -= 1
                            continue
                        break
                    if retry > 0:
                        check_point.done()
                    else:
                        set_cpus.reset()
                        return False
                set_cpus.reset()
    return True