-
Notifications
You must be signed in to change notification settings - Fork 7
Add benchmark measurements #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
bf86c2f
5ac547e
fe76c9b
baa107b
8de052c
6be08f1
790ad17
e688d63
e6aca17
fb9e266
376b8db
ff45935
6473e2a
107e9c8
a68d232
a7616af
870b9fc
f067d70
bd0def0
6699aa1
e1f9892
9754f98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,14 @@ | ||
| [submodule "src/instrumentation_measurement/evmone"] | ||
| path = src/instrumentation_measurement/evmone | ||
| url = ../evmone.git | ||
| [submodule "src/instrumentation_measurement/geth_benchmark"] | ||
| path = src/instrumentation_measurement/geth_benchmark | ||
| url = https://github.com/imapp-pl/go-ethereum | ||
| branch = imapp_benchmark | ||
| [submodule "src/instrumentation_measurement/nethermind_benchmark"] | ||
| path = src/instrumentation_measurement/nethermind_benchmark | ||
| url = https://github.com/imapp-pl/nethermind.git | ||
| branch = imapp_benchmark | ||
| [submodule "src/instrumentation_measurement/go-ethereum"] | ||
| path = src/instrumentation_measurement/go-ethereum | ||
| url = git@github.com:imapp-pl/go-ethereum.git | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build | ||
|
|
||
| WORKDIR /srv/app | ||
| RUN git clone --single-branch --branch imapp_benchmark https://github.com/imapp-pl/nethermind.git | ||
|
|
||
| WORKDIR /srv/app/nethermind | ||
| RUN git submodule update --init src/Dirichlet src/int256 src/Math.Gmp.Native | ||
|
|
||
| WORKDIR /srv/app/nethermind/src/Nethermind | ||
| RUN dotnet build -c Release Benchmarks.sln | ||
|
|
||
|
|
||
| FROM python:3.8 AS python | ||
|
|
||
| COPY ./src/program_generator /srv/app/src/program_generator | ||
| WORKDIR /srv/app/ | ||
| RUN pip install -r src/program_generator/requirements.txt | ||
|
|
||
| COPY ./src/instrumentation_measurement/measurements.py /srv/app/src/instrumentation_measurement/measurements.py | ||
| COPY --from=build /srv/app/nethermind/src/Nethermind/Imapp.Benchmark.Runner/bin /srv/app/src/instrumentation_measurement/nethermind_benchmark/src/Nethermind/Imapp.Benchmark.Runner/bin | ||
| COPY --from=build /srv/app/nethermind/src/Nethermind/Imapp.Measurement.Runner/bin /srv/app/src/instrumentation_measurement/nethermind_benchmark/src/Nethermind/Imapp.Measurement.Runner/bin | ||
|
|
||
| WORKDIR /srv/app/ | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,7 +64,7 @@ def __init__(self): | |
| reader = csv.DictReader(sys.stdin, delimiter=',', quotechar='"') | ||
| self._programs = [self._program_from_csv_row(row) for row in reader] | ||
|
|
||
| def measure(self, sampleSize, mode="all", evm="geth", nSamples=1): | ||
| def measure(self, sampleSize=1, mode="all", evm="geth", nSamples=1): | ||
| """ | ||
| Main entrypoint of the CLI tool. | ||
|
|
||
|
|
@@ -81,21 +81,23 @@ def measure(self, sampleSize, mode="all", evm="geth", nSamples=1): | |
| openethereum = "openethereum" | ||
| openethereum_ewasm = "openethereum_ewasm" | ||
| evmone = "evmone" | ||
| nethermind = "nethermind" | ||
|
|
||
| measure_total = "total" | ||
| measure_all = "all" | ||
| trace_opcodes = "trace" | ||
| benchmark_mode = "benchmark" | ||
|
|
||
| if not self._check_clocksource(): | ||
| print("clocksource should be tsc, found something different. See docker_timer.md somewhere in the docs") | ||
| return | ||
|
|
||
| if evm not in {geth, openethereum, evmone, openethereum_ewasm}: | ||
| print("Wrong evm parameter. Allowed are: {}, {}, {}, {}".format(geth, openethereum, evmone, openethereum_ewasm)) | ||
| if evm not in {geth, openethereum, evmone, openethereum_ewasm, nethermind}: | ||
| print("Wrong evm parameter. Allowed are: {}, {}, {}, {}".format(geth, openethereum, evmone, openethereum_ewasm, nethermind)) | ||
| return | ||
|
|
||
| if mode not in {measure_total, measure_all, trace_opcodes}: | ||
| print("Invalid measurement mode. Allowed options: {}, {}, {}".format(measure_total, measure_all, trace_opcodes)) | ||
| if mode not in {measure_total, measure_all, trace_opcodes, benchmark_mode}: | ||
| print("Invalid measurement mode. Allowed options: {}, {}, {}".format(measure_total, measure_all, trace_opcodes, benchmark_mode)) | ||
| return | ||
| elif mode == measure_total: | ||
| header = "program_id,sample_id,run_id,measure_total_time_ns,measure_total_timer_time_ns" | ||
|
|
@@ -108,21 +110,34 @@ def measure(self, sampleSize, mode="all", evm="geth", nSamples=1): | |
| for i in range(MAX_OPCODE_ARGS): | ||
| elem = ",arg_{}".format(i) | ||
| header += elem | ||
|
|
||
| print(header) | ||
| elif mode == benchmark_mode: | ||
| if evm == geth: | ||
| header = "program_id,sample_id,run_id,iterations_count,engine_overhead_time_ns,execution_loop_time_ns,total_time_ns,mem_allocs_count,mem_allocs_bytes" | ||
| elif evm == nethermind: | ||
| header = "program_id,sample_id,run_id,iterations_count,engine_overhead_time_ns,execution_loop_time_ns,total_time_ns,std_dev_time_ns,mem_allocs_count,mem_allocs_bytes" | ||
| print(header) | ||
|
|
||
|
|
||
| for program in self._programs: | ||
| for sample_id in range(nSamples): | ||
| instrumenter_result = None | ||
| if evm == geth: | ||
| instrumenter_result = self.run_geth(mode, program, sampleSize) | ||
| if mode == benchmark_mode: | ||
| instrumenter_result = self.run_geth_benchmark(program, sampleSize) | ||
| else: | ||
| instrumenter_result = self.run_geth(mode, program, sampleSize) | ||
| elif evm == openethereum: | ||
| instrumenter_result = self.run_openethereum(mode, program, sampleSize) | ||
| elif evm == openethereum_ewasm: | ||
| instrumenter_result = self.run_openethereum_wasm(program, sampleSize) | ||
| elif evm == evmone: | ||
| instrumenter_result = self.run_evmone(mode, program, sampleSize) | ||
| elif evm == nethermind: | ||
| if mode == benchmark_mode: | ||
| instrumenter_result = self.run_nethermind_benchmark(program, sampleSize) | ||
| else: | ||
| instrumenter_result = self.run_nethermind(program, sampleSize) | ||
|
|
||
| if mode == trace_opcodes: | ||
| instrumenter_result = self.sanitize_tracer_result(instrumenter_result) | ||
|
|
@@ -145,6 +160,41 @@ def run_geth(self, mode, program, sampleSize): | |
|
|
||
| return instrumenter_result | ||
|
|
||
| def run_geth_benchmark(self, program, sampleSize): | ||
| geth_benchmark = ['./instrumentation_measurement/geth_benchmark/tests/imapp_benchmark/imapp_benchmark'] | ||
|
|
||
| # alternative just-in-time compilation (could run 50% slower) | ||
| # geth_benchmark = ['go', 'run', './instrumentation_measurement/geth_benchmark/tests/imapp_benchmark/imapp_bench.go'] | ||
|
|
||
| args = ['--sampleSize', '{}'.format(sampleSize)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It still makes sense in that the sample size means the number of benchmark runs. The default is 1, but we can run benchmark multiple times. |
||
| bytecode_arg = ['--bytecode', program.bytecode] | ||
| invocation = geth_benchmark + args + bytecode_arg | ||
| result = subprocess.run(invocation, stdout=subprocess.PIPE, universal_newlines=True) | ||
| assert result.returncode == 0 | ||
| # strip the final newline | ||
| instrumenter_result = result.stdout.split('\n')[:-1] | ||
| return instrumenter_result | ||
|
|
||
| def run_nethermind(self, program, sampleSize): | ||
| geth_benchmark = ['./instrumentation_measurement/nethermind_benchmark/src/Nethermind/Imapp.Measurement.Runner/bin/Release/net6.0/Imapp.Measurement.Runner'] | ||
| args = ['--bytecode', program.bytecode, '--print-csv', '--sample-size={}'.format(sampleSize)] | ||
| invocation = geth_benchmark + args | ||
| result = subprocess.run(invocation, stdout=subprocess.PIPE, universal_newlines=True) | ||
| assert result.returncode == 0 | ||
| # strip the final newline | ||
| instrumenter_result = result.stdout.split('\n')[:-1] | ||
| return instrumenter_result | ||
|
|
||
| def run_nethermind_benchmark(self, program, sampleSize): | ||
| geth_benchmark = ['./instrumentation_measurement/nethermind_benchmark/src/Nethermind/Imapp.Benchmark.Runner/bin/Release/net6.0/Imapp.Benchmark.Runner'] | ||
| args = ['--bytecode', program.bytecode, '--print-csv', '--sample-size={}'.format(sampleSize)] | ||
| invocation = geth_benchmark + args | ||
| result = subprocess.run(invocation, stdout=subprocess.PIPE, universal_newlines=True) | ||
| assert result.returncode == 0 | ||
| # strip the final newline | ||
| instrumenter_result = result.stdout.split('\n')[:-1] | ||
| return instrumenter_result | ||
|
|
||
| def run_openethereum(self, mode, program, sampleSize): | ||
| openethereum_build_path = './instrumentation_measurement/openethereum/target/release/' | ||
| openethereum_main = [openethereum_build_path + 'openethereum-evm'] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.