Skip to content

dynamic tx_num (in a block) depending on workload #224

@0xmountaintop

Description

@0xmountaintop

before

for now we use fixed n_tx

pub fn flush_with_nop(&mut self) {
    let mut cnt = 0;
    while self.buffered_txs.len() % self.n_tx != 0 {
        self.nop();
        cnt += 1;
    }
    log::debug!("flush with {} nop", cnt);
}

n_tx is params::NTXS

after

we should replace params::NTXS with params::TX_SLOT_NUM
for example,

TX_SLOT_NUM = [2, 16, 64, 512]

use

pub fn parse_env_to_collection<F, I>(name: &str) -> F
where
    I: FromStr,
    I::Err: std::fmt::Debug,
    F: FromIterator<I>,
{
    get_env(name)
        .split(',')
        .map(|p| p.parse::<I>().unwrap())
        .collect()
}

and then sort them

compare one by one (basic idea, should use for loop or iter:

if self.buffered_txs.len() > 512 * 10 {
    n_tx = 512
} else if self.buffered_txs.len() > 64 * 10 {
    n_tx = 64
} else if self.buffered_txs.len() > 16 * 10 {
    n_tx = 16
} ....

then flush_with_nop

also need the same logic to decide n_tx in pop_all_blocks

we should also record whether it's a large or medium or small block
I think we can record this info in pop_all_blocks's forge_with_txs?
so we add block_type (small, medium, large) in L2BlockDetail

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions