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

Change architecture of Workers pool #329

Merged
merged 9 commits into from
Oct 17, 2022

Commits on Oct 17, 2022

  1. fix: small performance improvement

    Do not duplicate in memory the contents of a Wasm module, just to read
    its metadata.
    
    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    d2ddd3a View commit details
    Browse the repository at this point in the history
  2. refactor: remove utils module

    Small refactoring, consolidate methods and functions inside of the
    `settings` module.
    
    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    9ee2f6d View commit details
    Browse the repository at this point in the history
  3. fix: update to latest Burrego release

    The latest Burrego releases breaks some APIs.
    
    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    edb0d6d View commit details
    Browse the repository at this point in the history
  4. fix: optimize policies download

    The same policy can be instantiated multiple times. Prior to this
    commit, the Downloader would download and verify the same WebAssembly module
    over and over again.
    
    Now the Download avoids doing that.
    
    Moreover, prior to this commit, the code mutated the list of policies
    provided as a parameter. That was done to add the local path to the
    WebAssembly module. The new code avoids doing this mutation, which was a
    bit ugly.
    
    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    d2867ef View commit details
    Browse the repository at this point in the history
  5. remove utils from main.rs

    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    053f49b View commit details
    Browse the repository at this point in the history
  6. together with downloader ref

    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    593a249 View commit details
    Browse the repository at this point in the history
  7. refactor: update internal communication struct

    Ensure the worker_pool receives the list of fetched policies.
    This is needed because now the `settings::Policy` structs do no
    longer have an attribute that holds this information. See previous
    commit.
    
    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    3528a75 View commit details
    Browse the repository at this point in the history
  8. refactor: reorganize workers

    This is a big refactoring of the WorkerPool and the Worker structs.
    
    The major changes done to WorkerPool:
    
    * Perform the validation of policies settings only once per policy.
    Prior to that, each worker validated the settings of all the policies.
    * Precompile all the WebAssembly modules once, then give the precompiled
      modules to the workers. This reduces the bootstrap time **a lot**.
    
    About the latter point, creating a `wasmtime::Module` by reading the
    contents of the `.wasm` file is an expensive operation. Prior to that,
    the same WebAssembly module was compiled by each worker.
    
    Note, we cannot rely on Wasmtime `cache` feature because, given the number of
    workers we start, there would be quite some resource contention among
    them.
    
    Changes done to the Worker:
    
    * Create one single `wasmtime::Engine` to be shared among all the
      Modules hosted by the Worker. This reduces resource usage and is
      needed to implement the "limit execution time of the policies"
      feature.
    * Instantiate the `wasmtime::Module` instances by using the precompiled
      objects prepared by the WorkerPool. This saves an insane amount of
      time at bootstrap time
    * Do not perform settings validation anymore. They have already been
      validated prior to the creation of the Worker
    
    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    fb00429 View commit details
    Browse the repository at this point in the history
  9. Update dependencies

    Use latest version of policy_evaluator, plus require the rayon crate
    which is now being used by the worker pool.
    
    Signed-off-by: Flavio Castelli <[email protected]>
    flavio committed Oct 17, 2022
    Configuration menu
    Copy the full SHA
    8bea4bd View commit details
    Browse the repository at this point in the history