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

clif-backend: Eliminate FunctionEnvironment construction in feed_event() #615

Merged
merged 2 commits into from
Aug 1, 2019

Commits on Aug 1, 2019

  1. clif-backend: Eliminate FunctionEnvironment construction in feed_event()

    The feed_event() function is called for every wasm binary instruction.
    Let's optimize it by storing FunctionEnvironment object in
    CraneliftFunctionCodeGenerator, rather than constructing it for every
    feed_event() invocation.
    
    This change reduces the time to run "ngix compile" benchmark by 68%:
    
    Before:
    
      nginx compile           time:   [1.4152 s 1.4186 s 1.4222 s]
      Found 1 outliers among 10 measurements (10.00%)
        1 (10.00%) high mild
    
    After:
    
      nginx compile           time:   [447.76 ms 448.32 ms 448.80 ms]
                              change: [-68.542% -68.440% -68.352%] (p = 0.00 < 0.05)
                              Performance has improved.
    
    I assume some of the clone() calls are very expensive (Vec::clone(),
    likely). I did see libc malloc()/free() high up in "perf top" profiles,
    which are eliminted by this change.
    
    I also looked into eliminating FunctionBuilder construction from
    feed_event(). That turns out to be painful on lifetime rules because it
    borrows bunch of other objects, so I am leaving it for someone who knows
    the code better than I do.
    penberg committed Aug 1, 2019
    Configuration menu
    Copy the full SHA
    869ac21 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dfef2b6 View commit details
    Browse the repository at this point in the history