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

Some performance issues #61

Closed
dalance opened this issue Mar 7, 2023 · 2 comments
Closed

Some performance issues #61

dalance opened this issue Mar 7, 2023 · 2 comments

Comments

@dalance
Copy link

dalance commented Mar 7, 2023

I found some small performance issues.

disable log

if parol_runtime provide log/release_max_level_off feature like below, Rust compiler can remove trace! macro statically.

[features]
max_level_off   = ["log/max_level_off"]
max_level_error = ["log/max_level_error"]
max_level_warn  = ["log/max_level_warn"]
max_level_info  = ["log/max_level_info"]
max_level_debug = ["log/max_level_debug"]
max_level_trace = ["log/max_level_trace"]
release_max_level_off   = ["log/release_max_level_off"]
release_max_level_error = ["log/release_max_level_error"]
release_max_level_warn  = ["log/release_max_level_warn"]
release_max_level_info  = ["log/release_max_level_info"]
release_max_level_debug = ["log/release_max_level_debug"]
release_max_level_trace = ["log/release_max_level_trace"]

I got 6% performance gain.

throughput/parse        time:   [11.043 ms 11.056 ms 11.073 ms]
                        thrpt:  [1.3537 MiB/s 1.3558 MiB/s 1.3574 MiB/s]
                 change:
                        time:   [-7.8789% -5.9537% -4.3499%] (p = 0.00 < 0.05)
                        thrpt:  [+4.5478% +6.3307% +8.5528%]
                        Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
  2 (2.00%) high mild
  4 (4.00%) high severe

remove is_empty before pop

VerylGrammarAuto::pop which is generated by parol has is_empty check.
It can be removed because pop will return None when the vec is empty.

fn pop(&mut self, context: &str) -> Option<ASTType> {
    //if !self.item_stack.is_empty() {
    let item = self.item_stack.pop();
    if let Some(ref item) = item {
        trace!("pop     {}: {:?}", context, item);
    }
    item
    //} else {
    //    None
    //}
}

I got 2% performance gain.

throughput/parse        time:   [10.867 ms 10.931 ms 11.023 ms]
                        thrpt:  [1.3599 MiB/s 1.3713 MiB/s 1.3793 MiB/s]
                 change:
                        time:   [-4.6804% -2.4878% -0.5493%] (p = 0.01 < 0.05)
                        thrpt:  [+0.5523% +2.5513% +4.9102%]
                        Change within noise threshold.
Found 14 outliers among 100 measurements (14.00%)
  5 (5.00%) high mild
  9 (9.00%) high severe
@jsinger67
Copy link
Owner

Thanks for your analysis.
Both are good points 👍
I will incorporate your suggestions in the next version.

jsinger67 added a commit that referenced this issue Mar 7, 2023
@jsinger67
Copy link
Owner

Fixed with commit f1661db.
New versions have not yet been released on crates.io.

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

No branches or pull requests

2 participants