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

refactor(papyrus_storage): add append_events function that writes the events of a block to storage #2900

Open
wants to merge 3 commits into
base: alonl/event_storage_split
Choose a base branch
from

Conversation

AlonLStarkWare
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link

Benchmark movements:
tree_computation_flow performance regressed!
tree_computation_flow time: [34.305 ms 34.803 ms 35.394 ms]
change: [+1.1333% +2.6378% +4.4345%] (p = 0.00 < 0.05)
Performance has regressed.
Found 13 outliers among 100 measurements (13.00%)
3 (3.00%) high mild
10 (10.00%) high severe

Copy link
Contributor

@ShahakShama ShahakShama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: 3 of 7 files reviewed, 4 unresolved discussions (waiting on @AlonLStarkWare)


crates/papyrus_storage/src/body/events.rs line 377 at r3 (raw file):

    DbCursor<'txn, RO, TransactionIndex, VersionZeroWrapper<TransactionMetadata>, SimpleTable>;

/// interface for updating the events in the storage.

capitalization


crates/papyrus_storage/src/body/events.rs line 382 at r3 (raw file):

    Self: Sized,
{
    /// Appends the events of an entire block to the storage.

Copy this comment:

// To enforce that no commit happen after a failure, we consume and return Self on success.


crates/papyrus_storage/src/body/events.rs line 386 at r3 (raw file):

        self,
        block_number: BlockNumber,
        block_events: Vec<Vec<Event>>,

Receive this by reference and as an array slice and not a vec: &[&[Event]]

In general if you don't need to consume the value it's better to pass it by reference (as long as you don't clone it anywhere)
Also, in general it's better to receive &[T] instead of &Vec as the former can handle the latter yet also handle different stuff like arrays (You'll find that useful in tests for example)


crates/papyrus_storage/src/body/events.rs line 425 at r3 (raw file):

    for (index, transaction_events) in block_events.iter().enumerate() {
        let transaction_index = TransactionIndex(block_number, TransactionOffsetInBlock(index));
        let event_offset = file_handlers.append_events(&transaction_events.clone());

Why clone?

@AlonLStarkWare AlonLStarkWare force-pushed the alonl/append_events branch 2 times, most recently from ab03de4 to 63f915f Compare December 25, 2024 13:14
Copy link
Contributor Author

@AlonLStarkWare AlonLStarkWare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 7 files reviewed, 4 unresolved discussions (waiting on @ShahakShama)


crates/papyrus_storage/src/body/events.rs line 377 at r3 (raw file):

Previously, ShahakShama wrote…

capitalization

Done.


crates/papyrus_storage/src/body/events.rs line 382 at r3 (raw file):

Previously, ShahakShama wrote…

Copy this comment:

// To enforce that no commit happen after a failure, we consume and return Self on success.

Done.


crates/papyrus_storage/src/body/events.rs line 386 at r3 (raw file):

Previously, ShahakShama wrote…

Receive this by reference and as an array slice and not a vec: &[&[Event]]

In general if you don't need to consume the value it's better to pass it by reference (as long as you don't clone it anywhere)
Also, in general it's better to receive &[T] instead of &Vec as the former can handle the latter yet also handle different stuff like arrays (You'll find that useful in tests for example)

Done.


crates/papyrus_storage/src/body/events.rs line 425 at r3 (raw file):

Previously, ShahakShama wrote…

Why clone?

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants