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

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

Open
0xmountaintop opened this issue Nov 8, 2021 · 3 comments · May be fixed by #236
Open

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

0xmountaintop opened this issue Nov 8, 2021 · 3 comments · May be fixed by #236
Assignees

Comments

@0xmountaintop
Copy link
Member

0xmountaintop commented Nov 8, 2021

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

@lispc
Copy link
Member

lispc commented Nov 9, 2021

i suggest a list. 'tx_slot_num'. eg [2, 16, 64, 512]

@0xmountaintop
Copy link
Member Author

i suggest a list. 'tx_slot_num'. eg [2, 16, 64, 512]

This loos good. But I am not sure whether it's easy to achieve based on current codes.

    pub static ref NTXS: usize = std::env::var("NTXS")
        .expect("NTXS not set in ENV")
        .parse::<usize>()
        .expect("parse NTXS");

@0xmountaintop
Copy link
Member Author

0xmountaintop commented Nov 9, 2021

maybe we should refactor the current params and use config.

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()
}

@silathdiir silathdiir self-assigned this Nov 12, 2021
@silathdiir silathdiir linked a pull request Nov 14, 2021 that will close this issue
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 a pull request may close this issue.

3 participants