Exemplo n.º 1
0
def _exec_cmd(cmd_str):
    print(cmd_str)
    set_benchmark_env()
    ret_code = call(cmd_str, shell=True, cwd=PROJ_ROOT)

    if ret_code != 0:
        raise RuntimeError("Command failed: {}".format(ret_code))
Exemplo n.º 2
0
def _run_sleep_bench(bench_name, n_workers, cmd, sleep_time, process_name, csv_out):
    print("BENCH: {} - {} workers".format(bench_name, n_workers))

    # Launch the process in the background
    cmd_str = [
        cmd,
        str(n_workers),
    ]
    cmd_str = " ".join(cmd_str)

    # Set up environment
    set_benchmark_env()

    # Launch subprocess
    sleep_proc = Process(target=_exec_cmd, args=[cmd_str])
    sleep_proc.start()
    sleep(sleep_time)

    pid = get_pid_for_name(process_name)
    print("Measuring memory of process {}".format(pid))
    mem_total = get_total_memory_for_pid(pid)

    for label, value in zip(mem_total.get_labels(), mem_total.get_data()):
        csv_out.write("{},{},{},{},{}\n".format(
            bench_name,
            label,
            value,
            n_workers,
            Decimal(value) / n_workers,
        ))

    csv_out.flush()

    # Rejoin the background process
    sleep_proc.join()
Exemplo n.º 3
0
def bench_tpt(ctx, runtime=None):
    repeats = 3

    if not exists(RESULT_DIR):
        makedirs(RESULT_DIR)

    csv_out = open(OUTPUT_FILE, "w")
    csv_out.write(
        "RunNum,Runtime,Duration,TargetThroughput,Throughput,LatencyMed,Latency90,Latency99\n"
    )
    csv_out.flush()

    set_benchmark_env()

    for r in range(repeats):
        print("Throughput benchmark repeat {}".format(r + 1))

        if runtime == "docker" or runtime is None:
            # NOTE - Docker tpt script needs delay in a seconds string and runtime in millis
            runs = [
                ("10", "30000"),
                ("8", "30000"),
                ("6", "25000"),
                ("4", "20000"),
                ("2", "15000"),
                ("1.5", "15000"),
                ("1.25", "15000"),
                ("1", "15000"),
                ("0.75", "15000"),
                ("0.5", "15000"),
                ("0.25", "15000"),
                ("0.15", "15000"),
            ]

            for delay, runtime_length in runs:
                # Run the bench
                cmd = [
                    join(PROJ_ROOT, "bin", "docker_tpt.sh"),
                    delay,
                    runtime_length,
                ]
                cmd_str = " ".join(cmd)

                _exec_cmd(cmd_str)

                # Write the result
                target_tpt = Decimal("1") / Decimal(delay)
                _write_tpt_lat(r, "docker", target_tpt, csv_out, tolerance=5)

        if runtime == "faasm" or runtime is None:
            # NOTE: both are in microseconds
            runs = [
                ("10000000", "30000"),
                ("6000000", "20000"),
                ("2000000", "15000"),
                ("1000000", "15000"),
                ("500000", "15000"),
                ("250000", "15000"),
                ("100000", "10000"),
                ("50000", "10000"),
                ("25000", "10000"),
                ("10000", "10000"),
                ("5000", "10000"),
                ("1000", "10000"),
                ("750", "10000"),
            ]

            for delay, runtime_length in runs:
                # Run the bench
                cmd = [
                    join(BENCHMARK_BUILD, "bin", "bench_tpt"),
                    delay,
                    runtime_length,
                ]
                cmd_str = " ".join(cmd)

                _exec_cmd(cmd_str)

                # Write the result
                target_tpt = (Decimal("1000000")) / Decimal(delay)
                _write_tpt_lat(r, "faasm", target_tpt, csv_out)

    csv_out.close()