GithubHelp home page GithubHelp logo

Comments (3)

Robbepop avatar Robbepop commented on May 28, 2024

Depends on new wasmparser updates:

from wasmi.

Robbepop avatar Robbepop commented on May 28, 2024

Using the following definitions for Wasmi's code_map.rs:

pub struct UncompiledFuncEntity {
    func_index: u32,
    bytes: SmallByteSlice,
    module: ModuleHeader,
    validate: Option<wasmparser::ValidatorResources>,
}

pub enum SmallByteSlice {
    Small {
        len: u8,
        bytes: [u8; 22],
    },
    Big(Box<[u8]>),
}
  • SmallByteSlice now stores 22 bytes inline instead of 30.
    • Note: With union and unsafe Rust trickery we could decrease the size of this type by another 8 bytes, however, for now I don't think the gains are worth this refactor.
  • Replaced func_to_validate: Option<wasmparser::FuncToValidate<wasmparser::ValidatorResources>> field with validate: Option<wasmparser::ValidatorResources> which is a lot smaller. The index and ty fields are redundantly stored in UncompiledFuncEntity::func_index field with access to module if we do some refactoring in ModuleHeader. Furthermore the features: WasmFeatures field is the same for all uncompiled function entities in the same Engine and thus can be stored in the CodeMap directly and reused.

All in all this nets us the following improvements in memory consumption:

  • size_of<UncompiledFuncEntity>(): 88 -> 48
  • size_of<InternalFuncEntity>(): 88 -> 48

Therefore, 40 bytes savings per function processed by the Engine.
For 1000 functions this is equivalent to 40kB.

from wasmi.

Robbepop avatar Robbepop commented on May 28, 2024

Blocked by bytecodealliance/wasm-tools#1493 and bytecodealliance/wasmtime#8341 (comment).

from wasmi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.