Crates.io | sparkles |
lib.rs | sparkles |
version | 0.1.4 |
source | src |
created_at | 2024-08-23 08:43:55.498267 |
updated_at | 2024-09-28 18:04:49.722707 |
description | Capture execution flow of your Rust application with CPU cycle precision! |
homepage | |
repository | https://github.com/skibon02/sparkles |
max_upload_size | |
id | 1348889 |
size | 68,096 |
Performance-focused library for capturing execution flow of application.
What?
Simply add the instant_event! macro to your code with a string literal and you'll be able to view this event later on a timeline with CPU cycle precision.
How?
Fast. Blazingly fast. 🚀 Recording a single event incurs an overhead as low as 10ns and consumes only 3 bytes in the trace buffer (in dense tracing conditions).
˚ ༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚ ༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚˚ ༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚ ༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚༘ ⋆。˚ ✧ ˚ ༘
Up to 🫸100_000_000🫷 events per second can be captured in a local environment with no data loss.
༘ ⋆。˚ ༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚༘ ⋆。˚ ✧ ˚ ༘ ⋆。˚༘ ⋆。˚ ✧ ˚
cargo add sparkles
cargo add sparkles-macro
use std::time::Duration;
use sparkles_macro::{instant_event, range_event_start};
// Refer to sparkles/examples/how_to_use.rs
fn main() {
let finalize_guard = sparkles::init_default();
let g = range_event_start!("main()");
let jh = std::thread::Builder::new().name(String::from("joined thread")).spawn(|| {
for _ in 0..100 {
instant_event!("^-^");
std::thread::sleep(Duration::from_micros(1_000));
}
}).unwrap();
std::thread::Builder::new().name(String::from("detached thread")).spawn(|| {
for _ in 0..30 {
instant_event!("*_*");
std::thread::sleep(Duration::from_micros(1_000));
}
}).unwrap();
for i in 0..1_000 {
instant_event!("✨✨✨");
std::thread::sleep(Duration::from_micros(10));
}
jh.join().unwrap();
}
trace/*.sprk
is generated.trace
folder.cargo run --example interactive
Go to https://ui.perfetto.dev and drag'n'drop resulting .perf
file.
Observe the result:
🌟 STD support
🌟 x86/x86_64/aarch64 architecture.
OR
🌟 Functioning Instant::now()
Single event overhead on average x86 machine (Intel i5-12400) is 9ns.
Ready:
🌟 Timestamp provider
🌟 Event name hashing
🌟 Perfetto json format compatibility (replaced with protobuf)
🌟 Ranges (scopes) support
🌟 Configuration support
🌟 Perfetto protobuf format support
🌟 Abstraction over events sending type (UDP/File)
🌟 Automatic timestamp frequency detection
🌟 aarch64 support
TODO:
⚙️ Include git revision into build
⚙️ Option to run without additional bg thread
⚙️ Defmt support
⚙️ Additional attached binary data
⚙️ Option to limit total consumed TLS buffer allocation
⚙️ Module info support: full module path, line of code
⚙️ Capture and transfer loss detection with no corruption to other captured and transmitted data
⚙️ Async support
⚙️ NO_STD implementation
⚙️ tags / hierarchy of events
⚙️ Viewer app
⚙️ Multi-app sync
⚙️ Global ranges
⚙️ Measurement overhead self-test
✧ accurate-timestamps-x86 - Enable serialization for x86/x86_64 timestamps
✧ self-tracing - Add global buffer flushing events
。゚゚・。・゚゚。
゚。SkyGrel19 ✨
゚・。・