Skip to content

Commit

Permalink
Remove dhat feature and imports (MystenLabs#6525)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtian authored Dec 6, 2022
1 parent c5a28be commit 493e22f
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 130 deletions.
48 changes: 0 additions & 48 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions crates/workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ der-parser = { version = "8", features = ["bigint", "num-bigint", "std"] }
derive_builder = { version = "0.12", features = ["std"] }
determinator = { version = "0.10", default-features = false }
deunicode = { version = "0.4", default-features = false }
dhat = { version = "0.3", default-features = false }
diesel = { version = "2", features = ["32-column-tables", "bitflags", "byteorder", "chrono", "itoa", "postgres", "postgres_backend", "pq-sys", "serde_json", "with-deprecated"] }
diff = { version = "0.1", default-features = false }
difference = { version = "2" }
Expand Down Expand Up @@ -308,7 +307,6 @@ mime = { version = "0.3", default-features = false }
mime_guess = { version = "2", default-features = false }
minimal-lexical = { version = "0.2", default-features = false, features = ["std"] }
miniz_oxide = { version = "0.5", default-features = false }
mintex = { version = "0.1", default-features = false }
mio-c38e5c1d305a1b54 = { package = "mio", version = "0.8", features = ["net", "os-ext", "os-poll"] }
mockall = { version = "0.11", default-features = false }
move-abigen = { git = "https://github.com/move-language/move", rev = "5bb2ac5a4a69e6f2df06183aec9b69c6d940f9f7", default-features = false }
Expand Down Expand Up @@ -535,7 +533,6 @@ subtle = { version = "2", default-features = false, features = ["i128", "std"] }
subtle-ng = { version = "2", default-features = false, features = ["std"] }
syn-dff4ba8e3ae991db = { package = "syn", version = "1", features = ["clone-impls", "derive", "extra-traits", "fold", "full", "parsing", "printing", "proc-macro", "quote", "visit", "visit-mut"] }
sync_wrapper = { version = "0.1", default-features = false }
sys-info = { version = "0.9", default-features = false }
tabular = { version = "0.2", features = ["ansi-cell", "strip-ansi-escapes", "unicode-width"] }
tap = { version = "1", default-features = false }
target-lexicon = { version = "0.12", features = ["std"] }
Expand All @@ -552,7 +549,6 @@ textwrap-a6292c17cd707f01 = { package = "textwrap", version = "0.11", default-fe
textwrap-3575ec1268b04181 = { package = "textwrap", version = "0.15", default-features = false }
textwrap-986da7b5efc2b80e = { package = "textwrap", version = "0.16", features = ["smawk", "unicode-linebreak", "unicode-width"] }
thiserror = { version = "1", default-features = false }
thousands = { version = "0.2", default-features = false }
thread_local = { version = "1", default-features = false }
threadpool = { version = "1", default-features = false }
thrift = { version = "0.16", features = ["log", "server", "threadpool"] }
Expand Down Expand Up @@ -815,7 +811,6 @@ derive_builder_macro = { version = "0.12", default-features = false }
derive_more = { version = "0.99", features = ["add", "add_assign", "as_mut", "as_ref", "constructor", "convert_case", "deref", "deref_mut", "display", "error", "from", "from_str", "index", "index_mut", "into", "into_iterator", "is_variant", "iterator", "mul", "mul_assign", "not", "rustc_version", "sum", "try_into", "unwrap"] }
determinator = { version = "0.10", default-features = false }
deunicode = { version = "0.4", default-features = false }
dhat = { version = "0.3", default-features = false }
diesel = { version = "2", features = ["32-column-tables", "bitflags", "byteorder", "chrono", "itoa", "postgres", "postgres_backend", "pq-sys", "serde_json", "with-deprecated"] }
diesel_derives = { version = "2", features = ["32-column-tables", "postgres", "with-deprecated"] }
diff = { version = "0.1", default-features = false }
Expand Down Expand Up @@ -981,7 +976,6 @@ mime = { version = "0.3", default-features = false }
mime_guess = { version = "2", default-features = false }
minimal-lexical = { version = "0.2", default-features = false, features = ["std"] }
miniz_oxide = { version = "0.5", default-features = false }
mintex = { version = "0.1", default-features = false }
mio-c38e5c1d305a1b54 = { package = "mio", version = "0.8", features = ["net", "os-ext", "os-poll"] }
mockall = { version = "0.11", default-features = false }
mockall_derive = { version = "0.11", default-features = false }
Expand Down Expand Up @@ -1256,7 +1250,6 @@ syn-3575ec1268b04181 = { package = "syn", version = "0.15", features = ["clone-i
syn-dff4ba8e3ae991db = { package = "syn", version = "1", features = ["clone-impls", "derive", "extra-traits", "fold", "full", "parsing", "printing", "proc-macro", "quote", "visit", "visit-mut"] }
sync_wrapper = { version = "0.1", default-features = false }
synstructure = { version = "0.12", features = ["proc-macro"] }
sys-info = { version = "0.9", default-features = false }
tabular = { version = "0.2", features = ["ansi-cell", "strip-ansi-escapes", "unicode-width"] }
tap = { version = "1", default-features = false }
target-lexicon = { version = "0.12", features = ["std"] }
Expand All @@ -1275,7 +1268,6 @@ textwrap-3575ec1268b04181 = { package = "textwrap", version = "0.15", default-fe
textwrap-986da7b5efc2b80e = { package = "textwrap", version = "0.16", features = ["smawk", "unicode-linebreak", "unicode-width"] }
thiserror = { version = "1", default-features = false }
thiserror-impl = { version = "1", default-features = false }
thousands = { version = "0.2", default-features = false }
thread_local = { version = "1", default-features = false }
threadpool = { version = "1", default-features = false }
thrift = { version = "0.16", features = ["log", "server", "threadpool"] }
Expand Down
19 changes: 9 additions & 10 deletions narwhal/benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ bench_params = {
'tx_size': 512,
'faults': 0,
'duration': 300,
'mem_profiling': False
}
```
They specify the number of primaries (`nodes`) and workers per primary (`workers`) to deploy, the input rate (transactions per second, or tx/s) at which the clients submit transactions to the system (`rate`), the size of each transaction in bytes (`tx_size`), the number of faulty nodes (`faults`), and the duration of the benchmark in seconds (`duration`). The minimum transaction size is 9 bytes; this ensures the transactions of a client are all different.
Expand Down Expand Up @@ -115,19 +114,19 @@ Here is sample output:
```
The 'Consensus TPS' and 'Consensus latency' report the average throughput and latency without considering the client, respectively. The consensus latency thus refers to the time elapsed between the block's creation and its commit. In contrast, `End-to-end TPS` and `End-to-end latency` report the performance of the whole system, starting from when the client submits the transaction. The end-to-end latency is often called 'client-perceived latency'. To accurately measure this value without degrading performance, the client periodically submits 'sample' transactions that are tracked across all the modules until they get committed into a block; the benchmark scripts use sample transactions to estimate the end-to-end latency.

### Memory/Allocation Profiling
### Memory / Allocation Profiling

There is an option to run the benchmark in memory allocation profiling mode. This slows down the benchmark,
replacing the global allocator with one which profiles allocations. It requires the `dhat-heap` compiler feature
to be turned on. To enable memory profiling mode, set the following benchmark options:
Memory profiling for benchmarks are possible via `jemalloc` on Linux. It can be enabled in the following way:

* `'mem_profiling': True`
* `duration`: This should be set to 5 minutes or longer
* Intall `jemalloc`, e.g. `sudo apt install libjemalloc-dev`
* Enable `jemalloc` by setting `export MALLOC_CONF=prof:true,prof_prefix:jeprof.out,lg_prof_interval:33` before launching the benchmark script.

`dhat-heap-*.json` files will be written to the benchmark dir, one for each primary.
You might not get files for all primaries as some primaries might die with a panic (see https://github.com/nnethercote/dhat-rs/issues/19).
Memory profiles with names `jeprof.out*` will be written to the currently directory.

To view the profiling information, use the [hosted viewer](https://nnethercote.github.io/dh_view/dh_view.html) or see [the viewing instructions](https://docs.rs/dhat/latest/dhat/index.html#viewing) for details.
To visualize the profile,

* Intall `graphviz`, e.g. `sudo apt install graphviz`
* `sudo jeprof --svg <path to Narwhal binary> <path to profile> > prof.svg`

## AWS Benchmarks
This repo integrates various Python scripts to deploy and benchmark the codebase on [Amazon Web Services (AWS)](https://aws.amazon.com). They are particularly useful to run benchmarks in the WAN, across multiple data centers. This section provides a step-by-step tutorial explaining how to use them.
Expand Down
9 changes: 2 additions & 7 deletions narwhal/benchmark/benchmark/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@ def clean_logs():
return f'rm -r {PathMaker.logs_path()} ; mkdir -p {PathMaker.logs_path()}'

@staticmethod
def compile(mem_profiling):
if mem_profiling:
params = ["--profile", "bench-profiling",
"--features", "benchmark dhat-heap"]
else:
params = ["--release", "--features", "benchmark"]
return ["cargo", "build", "--quiet"] + params
def compile():
return ["cargo", "build", "--quiet", "--release", "--features", "benchmark"]

@staticmethod
def generate_key(filename):
Expand Down
5 changes: 0 additions & 5 deletions narwhal/benchmark/benchmark/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,6 @@ def __init__(self, json):

self.duration = int(json['duration'])

if 'mem_profiling' in json:
self.mem_profile = bool(json['mem_profiling'])
else:
self.mem_profile = False

self.runs = int(json['runs']) if 'runs' in json else 1
except KeyError as e:
raise ConfigError(f'Malformed bench parameters: missing key {e}')
Expand Down
4 changes: 2 additions & 2 deletions narwhal/benchmark/benchmark/full_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ def run(self, debug=False):
sleep(0.5) # Removing the store may take time.

# Recompile the latest code.
cmd = CommandMaker.compile(mem_profiling=self.mem_profile)
cmd = CommandMaker.compile()
subprocess.run(cmd, check=True, cwd=PathMaker.node_crate_path())
# Recompile the latest code.
cmd = CommandMaker.compile(mem_profiling=self.mem_profile)
cmd = CommandMaker.compile()
subprocess.run(cmd, check=True,
cwd=PathMaker.examples_crate_path())

Expand Down
2 changes: 1 addition & 1 deletion narwhal/benchmark/benchmark/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run(self, debug=False):
sleep(0.5) # Removing the store may take time.

# Recompile the latest code.
cmd = CommandMaker.compile(mem_profiling=self.mem_profile)
cmd = CommandMaker.compile()
Print.info(f"About to run {cmd}...")
subprocess.run(cmd, check=True, cwd=PathMaker.node_crate_path())

Expand Down
6 changes: 2 additions & 4 deletions narwhal/benchmark/benchmark/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ def _update(self, hosts, bench_parameters):
Print.info(
f'Updating {len(ips)} machines (branch "{self.settings.branch}")...'
)
compile_cmd = ' '.join(CommandMaker.compile(
mem_profiling=bench_parameters.mem_profile))
compile_cmd = ' '.join(CommandMaker.compile())
cmd = [
f'(cd {self.settings.repo_name} && git fetch -f)',
f'(cd {self.settings.repo_name} && git checkout -f {self.settings.branch} --)',
Expand All @@ -171,8 +170,7 @@ def _config(self, hosts, node_parameters, bench_parameters):
sleep(0.5) # Removing the store may take time.

# Recompile the latest code.
cmd = CommandMaker.compile(
mem_profiling=bench_parameters.mem_profile)
cmd = CommandMaker.compile()
Print.info(f"About to run {cmd}...")
subprocess.run(cmd, check=True, cwd=PathMaker.node_crate_path())

Expand Down
2 changes: 1 addition & 1 deletion narwhal/benchmark/benchmark/seed.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def run(self, starting_data_port):
sleep(0.5) # Removing the store may take time.

# Recompile the latest code.
cmd = CommandMaker.compile(mem_profiling=self.mem_profile)
cmd = CommandMaker.compile()
subprocess.run(cmd, check=True, cwd=PathMaker.node_crate_path())

# Create alias for the client and nodes binary.
Expand Down
4 changes: 0 additions & 4 deletions narwhal/benchmark/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def local(ctx, debug=True):
'rate': 50_000,
'tx_size': 512,
'duration': 20,
'mem_profiling': False
}
node_params = {
'header_num_of_batches_threshold': 32,
Expand Down Expand Up @@ -71,7 +70,6 @@ def demo(ctx, debug=True):
'rate': 50_000,
'tx_size': 512,
'duration': 10,
'mem_profiling': False
}
node_params = {
"batch_size": 500000,
Expand Down Expand Up @@ -123,7 +121,6 @@ def seed(ctx, starting_data_port):
'rate': 50_000,
'tx_size': 512,
'duration': 20,
'mem_profiling': False
}
try:
SeedData(bench_params).run(int(starting_data_port))
Expand Down Expand Up @@ -197,7 +194,6 @@ def remote(ctx, debug=False):
'tx_size': 512,
'duration': 300,
'runs': 2,
'mem_profiling': False
}
node_params = {
'header_num_of_batches_threshold': 32,
Expand Down
2 changes: 0 additions & 2 deletions narwhal/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ bincode = "1.3.3"
bytes = "1.3.0"
cfg-if = "1.0.0"
clap = "2.34"
dhat = { version = "0.3.2", optional = true }
futures = "0.3.24"
multiaddr = "0.16.0"
rand = "0.8.5"
Expand Down Expand Up @@ -61,7 +60,6 @@ test-utils = { path = "../test-utils", package = "narwhal-test-utils" }

[features]
benchmark = ["worker/benchmark", "primary/benchmark", "consensus/benchmark"]
dhat-heap = ["dhat"] # if you are doing heap profiling
trace_transaction = ["worker/trace_transaction"]

[[bin]]
Expand Down
32 changes: 0 additions & 32 deletions narwhal/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,6 @@ impl Node {
(None, NetworkModel::PartiallySynchronous)
};

// Inject memory profiling here if we build with dhat-heap feature flag
// Put name of primary in heap profile to distinguish diff primaries
#[cfg(feature = "dhat-heap")]
let profiler = {
use fastcrypto::traits::EncodeDecodeBase64;
use std::path::Path;

let heap_file = format!("dhat-heap-{}.json", name.encode_base64());
Arc::new(
dhat::Profiler::builder()
.file_name(Path::new(&heap_file))
.build(),
)
};

// Spawn the primary.
let primary_handles = Primary::spawn(
name.clone(),
Expand All @@ -157,23 +142,6 @@ impl Node {
);
handles.extend(primary_handles);

// Let's spin off a separate thread that waits a while then dumps the profile,
// otherwise this function exits immediately and the profile is dumped way too soon.
// See https://github.com/nnethercote/dhat-rs/issues/19 for a panic that happens,
// but at least 2 primaries should complete and dump their profiles.
#[cfg(feature = "dhat-heap")]
{
use std::time::Duration;

#[allow(clippy::redundant_clone)]
let profiler2 = profiler.clone();
std::thread::spawn(|| {
std::thread::sleep(Duration::from_secs(240));
println!("Dropping DHAT profiler...");
drop(profiler2);
});
}

Ok(handles)
}

Expand Down
Loading

0 comments on commit 493e22f

Please sign in to comment.