Beispiel #1
0
def Run(benchmark_spec):
    """Run YCSB against Redis.

  This method can run with multiple number of redis processes (server) on a
  single vm. Since redis is single threaded, there is no need to run on
  multiple server instances. When running with multiple redis processes, key
  space is sharded.

  This method can also run with muliple number of ycsb processes (client) on
  multiple client instances. Each ycsb process can only run against a single
  server process. The number of ycsb processes should be no smaller than
  the number of server processes or the number of client vms.

  To avoid having multiple ycsb processes on the same client vm
  targeting the same server process, this method hash ycsb processes to server
  processes and ycsb processes to client vms differently.

  Args:
    benchmark_spec: The benchmark specification. Contains all data that is
        required to run the benchmark.

  Returns:
    A list of sample.Sample objects.
  """
    groups = benchmark_spec.vm_groups
    ycsb_vms = groups['clients']
    num_ycsb = FLAGS.redis_ycsb_processes
    num_server = FLAGS.redis_total_num_processes
    num_client = FLAGS.ycsb_client_vms
    metadata = {
        'ycsb_client_vms': num_client,
        'ycsb_processes': num_ycsb,
        'redis_total_num_processes': num_server,
        'redis_server_version': FLAGS.redis_server_version
    }

    # Matching client vms and ycsb processes sequentially:
    # 1st to xth ycsb clients are assigned to client vm 1
    # x+1th to 2xth ycsb clients are assigned to client vm 2, etc.
    # Duplicate VirtualMachine objects passed into YCSBExecutor to match
    # corresponding ycsb clients.
    duplicate = int(math.ceil(num_ycsb / float(num_client)))
    client_vms = [vm for item in ycsb_vms
                  for vm in repeat(item, duplicate)][:num_ycsb]

    samples = list(
        benchmark_spec.executor.Load(client_vms, load_kwargs={'threads': 4}))
    vm_util.StartSimulatedMaintenance()
    samples += list(benchmark_spec.executor.Run(client_vms))

    for sample in samples:
        sample.metadata.update(metadata)

    return samples
def Run(bm_spec: _BenchmarkSpec) -> List[sample.Sample]:
    """Run memtier_benchmark against Redis."""
    client_vms = bm_spec.vm_groups['clients']
    # Don't reference vm_groups['server'] directly, because this is reused by
    # kubernetes_redis_memtier_benchmark, which doesn't have one.
    measure_cpu_on_server_vm = (REDIS_MEMTIER_MEASURE_CPU.value
                                and 'servers' in bm_spec.vm_groups)

    ports = [str(port) for port in redis_server.GetRedisPorts()]

    def DistributeClientsToPorts(port):
        client_index = int(port) % len(ports) % len(client_vms)
        vm = client_vms[client_index]
        return memtier.RunOverAllThreadsPipelinesAndClients(
            vm, bm_spec.redis_endpoint_ip, port)

    benchmark_metadata = {}

    # if testing performance due to a live migration, simulate live migration.
    # actual live migration timestamps is not reported by PKB.
    if FLAGS.simulate_maintenance:
        vm_util.StartSimulatedMaintenance()
        simulate_maintenance_time = datetime.datetime.now(
        ) + datetime.timedelta(seconds=FLAGS.simulate_maintenance_delay)
        benchmark_metadata['simulate_maintenance_time'] = str(
            simulate_maintenance_time)
        benchmark_metadata[
            'simulate_maintenance_delay'] = FLAGS.simulate_maintenance_delay
    if measure_cpu_on_server_vm:
        server_vm = bm_spec.vm_groups['servers'][0]
        top_cmd = f'top -b -d 1 -n {memtier.MEMTIER_RUN_DURATION.value} > {_TOP_OUTPUT} &'
        server_vm.RemoteCommand(f'echo "{top_cmd}" > {_TOP_SCRIPT}')
        server_vm.RemoteCommand(f'bash {_TOP_SCRIPT}')

    raw_results = vm_util.RunThreaded(DistributeClientsToPorts, ports)
    redis_metadata = redis_server.GetMetadata()

    top_results = []
    if measure_cpu_on_server_vm:
        top_results = _GetTopResults(server_vm)

    results = []

    for server_result in raw_results:
        for result_sample in server_result:
            result_sample.metadata.update(redis_metadata)
            result_sample.metadata.update(benchmark_metadata)
            results.append(result_sample)

    return results + top_results
def Run(bm_spec: _BenchmarkSpec) -> List[sample.Sample]:
    """Run memtier_benchmark against Redis."""
    client_vms = bm_spec.vm_groups['clients']

    # if testing performance due to a live migration, simulate live migration.
    # actual live migration timestamps is not reported by PKB.
    if FLAGS.simulate_maintenance:
        vm_util.StartSimulatedMaintenance()

    results = memtier.RunOverAllThreadsPipelinesAndClients(
        client_vms[0], bm_spec.redis_endpoint_ip,
        str(redis_server.DEFAULT_PORT))
    redis_metadata = redis_server.GetMetadata()
    for result_sample in results:
        result_sample.metadata.update(redis_metadata)
    return results