Ejemplo n.º 1
0
def clear_cache():
    """Dump all dirty data and clear file system cache
    (including directory cache)..
    """
    osutil.check_root_or_exit('No enough privilege to clear cache')
    system = platform.system()
    if system == 'Linux':
        status = call('sync', shell=True)
        if status:
            print >> sys.stderr, 'clear_cache: error on do sync'
            return -1
        status = call('echo 3 > /proc/sys/vm/drop_caches', shell=True)
        if status:
            print >> sys.stderr, 'clear_cache: error on drop caches'
    else:
        print >> sys.stderr, \
            'Error: clear_cache(): unsupported system: %s' % system
        sys.exit(1)
Ejemplo n.º 2
0
def main():
    """Filebench tests
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('-f', '--formats', metavar='FS,..',
                        default=FILE_SYSTEMS,
                        help='sets testing file systems (default: {}).'
                        .format(FILE_SYSTEMS))
    parser.add_argument('-w', '--workloads', metavar='NAME,..',
                        default=WORKLOADS,
                        help='set workloads, separated by comma. (default: {})'
                        .format(','.join(WORKLOADS)))
    parser.add_argument('-i', '--iteration', metavar='NUM', type=int,
                        default=1, help='set iteration, default: 1')
    parser.add_argument('-s', '--iosize', metavar='NUM', type=int,
                        default=1024, help='set IOSIZE (default: 1024)')
    parser.add_argument('-r', '--run', metavar='NUM', type=int,
                        default=60, help='set run time (default: 60)')
    parser.add_argument('--no_profile', action='store_true', default=False,
                        help='disable running profiling tools')
    parser.add_argument('-j', '--no-journal', action='store_true',
                        default=False, help='turn off journaling on ext4.')
    parser.add_argument('--perf', default='perf',
                        help='set the location of "perf"')
    parser.add_argument('-e', '--events', default='cycles', metavar='EVT,..',
                        help='set the events to monitor by perf '
                             '(default: cycles)')
    parser.add_argument('-k', '--vmlinux', default=None, metavar='FILE',
                        help='set vmlinux pathname for perf (optional)')
    parser.add_argument('-S', '--kallsyms', default=None, metavar='FILE',
                        help='set kallsyms pathname for perf (optional)')
    parser.add_argument('-R', '--retry', type=int, metavar='NUM', default=5,
                        help='Retry hanging benchmark (default: %(default)d)')

    subs = parser.add_subparsers()

    parser_scale = subs.add_parser('scale', help='Test scalability by running'
                                   ' multiprocess on all CPUs.')
    parser.add_argument('-p', '--nproc', metavar='nproc',
                        action=SplitCommaAction, default=range(4, 61, 4),
                        help='sets the number of processes to test.')
    parser_scale.set_defaults(func=test_scalability)

    # Options for sub-command 'cpuscale'
    parser_cpuscale = subs.add_parser(
        'cpuscale', help='Test CPU scale test with different numbers of '
        'active CPUs.')
    parser_cpuscale.add_argument(
        '-c', '--cpus', metavar='cpus', action=SplitCommaAction,
        default=range(4, 49, 4),
        help='sets the number of activate CPUs to test.')
    parser_cpuscale.add_argument(
        '-p', '--process', type=int, metavar='NUM',
        default=128, help='set the number of processes (default: %(default)d)')
    parser_cpuscale.add_argument(
        '-t', '--thread', type=int, metavar='NUM',
        default=1, help='set the number of threads (default: %(default)d)')
    parser_cpuscale.set_defaults(func=test_cpu_scale)

    parser_numa = subs.add_parser('numa', help='Test NUMA architecture.')
    parser_numa.add_argument('-n', '--disks', type=int, metavar='NUM',
                             default=1, help='set the number of disks to run.')
    parser_numa.add_argument(
        '-N', '--dirs', type=int, metavar='NUM', default=1,
        help='set the number of directories in each disk.')
    parser_numa.set_defaults(func=test_numa)

    parser_multifs = subs.add_parser('multifs', help='Test multi-filesystem.')
    parser_multifs.add_argument('--ndisks', metavar='NUM',
                                action=SplitCommaAction, default=range(1, 5),
                                help='sets the number of disks to run')
    parser_multifs.set_defaults(func=test_multi_filesystem)

    parser_run = subs.add_parser('run', help='Test run filebench directly.')
    parser_run.add_argument('-n', '--disks', type=int, metavar='NUM',
                            default=4, help='set the number of disks to run.')
    parser_run.add_argument('-N', '--dirs', type=int, metavar='NUM',
                            default=1,
                            help='set the number of directories in each disk.')
    parser_run.add_argument('-p', '--process', type=int, metavar='NUM',
                            default=1, help='set the number of processes in one'
                            ' filebench instance.')
    parser_run.add_argument('-t', '--thread', type=int, metavar='NUM',
                            default=1, help='set the number of threads.')
    parser_run.add_argument(
        '-b', '--basedir', metavar='DIR', default='ramdisks',
        help='set base dir to mount disks and run the test.')
    parser_run.add_argument(
        '-w', '--workload', metavar='STR', default='varmail',
        help='set workload to run.')
    parser_run.add_argument('-o', '--output', metavar='FILE', default=None,
                            help='set the output file.')
    parser_run.add_argument(
        '--timeout', metavar='SEC', type=int, default=600,
        help="set the timeout of waiting process to finish, "
             "default: %(default)d seconds.")
    parser_run.add_argument('--affinity', action='store_true', default=False,
                            help='set CPU affinity for each group of threads')
    parser_run.set_defaults(func=test_run)

    args = parser.parse_args()
    if 'func' not in args:
        parser.print_help()
        sys.exit(1)

    global PERF
    PERF = args.perf
    osutil.check_root_or_exit()
    return args.func(args)