poanetwork / hbbft

An implementation of the paper "Honey Badger of BFT Protocols" in Rust. This is a modular library of consensus.
Other
357 stars 96 forks source link

Add an EventLog for collecting metrics on hbbft performance #335

Open alyjak opened 6 years ago

alyjak commented 6 years ago

In order to propagate performance information into an hbbft caller, add an event_log to Steps definition. Events will implement failure::Fault, simply because it is a convenient interface for defining event types as well as annotating them formatted Display messages.

By including event_log in Step, logs will be naturally extended across calls and provided to the initial caller.

EventLog has a similar signature to FaultLog

pub struct `EventLog(pub Vec<Event>);

Events are similar to the Fault struct, but instead of node_id, they record a timestamp:

pub struct Event<L: Fail> {
    logtime: std::time::Instant,
    content: L
};

This way, the caller can record duration between two events using std::time::Instant::duration_since. Instants are monotonically increasing. They can be mapped to system time by logging a message who's contents is current OS system time. This way both clocks can be synchronized.

Besides measuring performance, event logs can be used by hbbft calling applications to detect soft failures, like a validator going off line, by collecting and monitoring logs over time.

If EventLog is added, a nice use case would be to add event logs to DistAlgorithm calls. So, the first time foo.handle_message is called it issues a log event, and when foo.handle_output produces an output a log event is also issued. Comparing this data between runs can be used to benchmark performance.