Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

EVM benchmark utilities #8944

Merged
merged 13 commits into from Jun 25, 2018
Merged

EVM benchmark utilities #8944

merged 13 commits into from Jun 25, 2018

Conversation

sorpaas
Copy link
Collaborator

@sorpaas sorpaas commented Jun 21, 2018

rel #8914, #6744

Expose jsontests helpers from ethcore so that they can be used elsewhere. Allow hooking to start/stop point of each test so that time information can be recorded. Add a command in evmbin:

parity-evm stats-jsontests-vm <file> [--folder]

This runs executive standard jsontests against a specific folder/file, record the timing information, and then output them in tsv format. This would allow those benchmark info to be compared.

evmbin/bench.sh is moved to scripts, and a new script is added, called evm_jsontests_bench.sh, which runs the above command on all available vm jsontests.

I also changed all scripts to use /usr/bin/env instead of /bin/bash. The later would mean it breaks on all non-FHS Linux systems (like NixOS).

@sorpaas sorpaas added A0-pleasereview 🤓 Pull request needs code review. M5-binaries 📦 External binaries (ethkey, ethstore, ethvm, etc.) labels Jun 21, 2018
@sorpaas sorpaas added this to the 1.12 milestone Jun 21, 2018
Copy link
Contributor

@ascjones ascjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Collaborator

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few grumbles, mostly on docs/discoverability.

use super::HookType;

/// Run chain jsontests on a given folder.
pub fn run_test_path<H: FnMut(&str, HookType)>(p: &Path, skip: &[&'static str], h: &mut H) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 7 identical pub fn run_test_path added in this PR – would it be possible to avoid some boilerplate and have a single copy?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those functions are wrappers for the parent run_test_path function. Before none of them are exposed, but I figured it would be helpful to add them there, as it simplify library user's work to figure out how those functions are meant to be used.

They're not entirely identical -- the function parameter passed is different, determining which type of tests it operates on. But I'm open to any idea if we can make this better and avoid duplications. :)

/// Indicate the type of the hook passed to test functions.
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum HookType {
/// Hook passed on starting of a test.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is better? "Hook to code to run on test start"

pub enum HookType {
/// Hook passed on starting of a test.
OnStart,
/// Hook passed on a test is finished.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is better? "Hook to code to run on test end"

@@ -21,7 +21,20 @@ use std::path::Path;
use std::ffi::OsString;
pub use ethereum_types::{H256, U256, Address};

pub fn run_test_path(p: &Path, skip: &[&'static str], runner: fn (json_data: &[u8]) -> Vec<String>) {
/// Indicate the type of the hook passed to test functions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "Indicate when to run the hook passed to test functions."?

@@ -76,6 +77,9 @@ State test options:
--only NAME Runs only a single test matching the name.
--chain CHAIN Run only tests from specific chain.

Stats jsontests VM options:
--folder Run jsontest for a folder instead of a single file.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this not be inferred from the input path? If it's a file => run the file; if it's a folder => run all tests within?

@@ -61,6 +61,7 @@ EVM implementation for Parity.
Usage:
parity-evm state-test <file> [--json --std-json --only NAME --chain CHAIN]
parity-evm stats [options]
parity-evm stats-jsontests-vm <file> [--folder]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the command in itself does not seem sufficient to understand what this does. Not sure where the best place to put a proper description of what it does and what the output format is would be, but I think it'd be very useful.

use std::collections::HashMap;
use std::time::{Instant, Duration};

let file = args.arg_file.expect("FILE is required");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"FILE (or PATH) is required"?


let file = args.arg_file.expect("FILE is required");

let mut times: HashMap<String, (Instant, Option<Duration>)> = HashMap::new();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: I suggest calling this timings.

@5chdn 5chdn added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jun 25, 2018
@5chdn 5chdn merged commit e9f1b38 into master Jun 25, 2018
@5chdn 5chdn deleted the sorpaas/evm-jsontests branch June 25, 2018 09:21
dvdplm added a commit that referenced this pull request Jun 25, 2018
* master:
  EVM benchmark utilities (#8944)
ordian added a commit to ordian/parity that referenced this pull request Jun 27, 2018
…rp_sync_on_light_client

* 'master' of https://github.com/paritytech/parity:
  parity: omit redundant last imported block number in light sync informant (openethereum#8962)
  Disable hardware-wallets on platforms that don't support `libusb` (openethereum#8464)
  Bump error-chain and quick_error versions (openethereum#8972)
  EVM benchmark utilities (openethereum#8944)
  parity: hide legacy options from cli --help (openethereum#8967)
  scripts: fix docker build tag on latest using master (openethereum#8952)
  Add type for passwords. (openethereum#8920)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M5-binaries 📦 External binaries (ethkey, ethstore, ethvm, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants