`air-trace` util for measuring AquaVM performance with tracing crate.
`air-trace run` subcommand allows to run AquaVM on any data, it allows to define most AquaVM inputs, providing defaults for most of them, and sets up either human-readable or JSON tracing output, the latter can be later processed by `air-trace stats`.
Anomaly data input is also supported, that is useful for slow data investigation.
Native execution mode can be used for native profiling. Please note, however, that current version cannot be built natively on Apple Sillicon processor yet, as invariably depends on the `avm-server` because of leaking types that should be refactored or hidden. The `--repeat` option can repeat the execution several times for the execution to dominate on input data reading and output.
High-level or rare calls have "info" trace level, instructions are "debug", and sub-instruction calls are "tracing". Over-detailed tracing can induce overhead that spoils timing data.
2022-07-07 14:44:58 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2022 Fluence Labs Limited
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
use std::time::Duration;
|
|
|
|
|
|
|
|
// unfortunately, external crates don't seem to provide required functionality:
|
|
|
|
// some do not handle floats, others do not handle suffixes
|
2024-01-30 21:43:47 +04:00
|
|
|
pub(crate) fn parse_tracing_duration(input: &str) -> Result<Duration, eyre::Error> {
|
`air-trace` util for measuring AquaVM performance with tracing crate.
`air-trace run` subcommand allows to run AquaVM on any data, it allows to define most AquaVM inputs, providing defaults for most of them, and sets up either human-readable or JSON tracing output, the latter can be later processed by `air-trace stats`.
Anomaly data input is also supported, that is useful for slow data investigation.
Native execution mode can be used for native profiling. Please note, however, that current version cannot be built natively on Apple Sillicon processor yet, as invariably depends on the `avm-server` because of leaking types that should be refactored or hidden. The `--repeat` option can repeat the execution several times for the execution to dominate on input data reading and output.
High-level or rare calls have "info" trace level, instructions are "debug", and sub-instruction calls are "tracing". Over-detailed tracing can induce overhead that spoils timing data.
2022-07-07 14:44:58 +03:00
|
|
|
for (suffix, scale) in [("ns", 1e-9), ("µs", 1e-6), ("ms", 1e-3), ("s", 1e0)] {
|
|
|
|
if let Some(num_str) = input.strip_suffix(suffix) {
|
|
|
|
if let Ok(num) = num_str.parse::<f64>() {
|
|
|
|
return Ok(Duration::from_secs_f64(num * scale));
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-10 12:27:06 +03:00
|
|
|
|
2024-01-30 21:43:47 +04:00
|
|
|
Err(eyre::eyre!("malformed duration {:?}", input))
|
`air-trace` util for measuring AquaVM performance with tracing crate.
`air-trace run` subcommand allows to run AquaVM on any data, it allows to define most AquaVM inputs, providing defaults for most of them, and sets up either human-readable or JSON tracing output, the latter can be later processed by `air-trace stats`.
Anomaly data input is also supported, that is useful for slow data investigation.
Native execution mode can be used for native profiling. Please note, however, that current version cannot be built natively on Apple Sillicon processor yet, as invariably depends on the `avm-server` because of leaking types that should be refactored or hidden. The `--repeat` option can repeat the execution several times for the execution to dominate on input data reading and output.
High-level or rare calls have "info" trace level, instructions are "debug", and sub-instruction calls are "tracing". Over-detailed tracing can induce overhead that spoils timing data.
2022-07-07 14:44:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn unix_timestamp_now() -> u64 {
|
|
|
|
use std::time::SystemTime;
|
|
|
|
|
|
|
|
SystemTime::now()
|
|
|
|
.duration_since(SystemTime::UNIX_EPOCH)
|
|
|
|
.expect("time befor Unix epoch")
|
|
|
|
.as_secs()
|
|
|
|
}
|