Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage): add latency metrics, minor debug message change and mi… #2112

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/papyrus_storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ pub struct StorageTxn<'env, Mode: TransactionKind> {

impl<'env> StorageTxn<'env, RW> {
/// Commits the changes made in the transaction to the storage.
#[latency_histogram("storage_commit_latency_seconds", false)]
pub fn commit(self) -> StorageResult<()> {
self.file_handlers.flush();
Ok(self.txn.commit()?)
Expand Down Expand Up @@ -701,11 +702,15 @@ impl FileHandlers<RW> {
}

// TODO(dan): Consider 1. flushing only the relevant files, 2. flushing concurrently.
#[latency_histogram("storage_file_handler_flush_latency_seconds", false)]
fn flush(&self) {
debug!("Flushing the mmap files.");
self.thin_state_diff.flush();
self.contract_class.flush();
self.casm.flush();
self.deprecated_contract_class.flush();
self.transaction_output.flush();
self.transaction.flush();
}

// Appends a thin transaction output to the corresponding file and returns its location.
Expand Down
4 changes: 2 additions & 2 deletions crates/papyrus_storage/src/mmap_file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl<V: ValueSerde> MMapFile<V> {

/// Flushes the mmap to the file.
fn flush(&mut self) {
debug!("Flushing mmap to file");
trace!("Flushing mmap to file");
self.mmap.flush().expect("Failed to flush the mmap");
self.should_flush = false;
}
Expand Down Expand Up @@ -231,7 +231,7 @@ impl<V: ValueSerde + Debug> Writer<V> for FileHandler<V, RW> {
{
let mut mmap_file = self.mmap_file.lock().expect("Lock should not be poisoned");
offset = mmap_file.offset;
debug!("Inserting object at offset: {}", offset);
trace!("Inserting object at offset: {}", offset);
let mmap_slice = &mut mmap_file.mmap[offset..];
mmap_slice[..len].copy_from_slice(&serialized);
mmap_file
Expand Down
2 changes: 1 addition & 1 deletion crates/papyrus_storage/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ fn write_replaced_classes<'env>(
Ok(())
}

#[latency_histogram("storage_write_storage_diffs_latency_seconds", true)]
#[latency_histogram("storage_write_storage_diffs_latency_seconds", false)]
fn write_storage_diffs<'env>(
storage_diffs: &IndexMap<ContractAddress, IndexMap<StorageKey, Felt>>,
txn: &DbTransaction<'env, RW>,
Expand Down
Loading