Giter Club home page Giter Club logo

component-opt's Introduction

component-opt

An optimizer for Wasm Components

Crates.io version Download docs.rs docs

Current Status

This project currently only offers one optimization and does not allow it to be configured.

That optimization is simply to unpack the modules within the component and optimize them. It makes extensive use of

  • wasmparser for parsing components,
  • wasm-opt for performing module optimization, and
  • wasm-encoder for constructing th output component.

The current testing methodology is explained in the Tests README

Goals

In the long run, I'd like this project to evolve to include "Component-aware" optimizations.

I've created a Optimization Pass Issue Tracker for proposed optimization passes.

component-opt's People

Contributors

esoterra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

component-opt's Issues

Dead Module Export Elimination

For any module which is not exported by the containing component, nothing can observe its imports and exports but that component.

So if an export of that module is not aliased in any instance of the module, that export can be removed from the module potentially enabling further module-level optimizations.

Module/Instance Inlining

It's possible combine together modules whose instances have export-alias-import relationships.

Benefits:

  • Further module-level optimizations may now be possible.
  • It may enable more dead item and dead module export elimination, reducing code size.

Considerations:

  • If there are modules which are completely disconnected/independent from others, it may not make sense to merge them.
  • If any modules are instantiated multiple times, this optimization could duplicate information depending on how it is configured.
  • If multiple instances define memories, then the resulting module may require multi-memory even if none of them individually did.

Dead Item Elimination

Any item in a section which introduces an unused index can be removed.

e.g. aliases, types

Canonical Option Elimination

Sometimes we can tell that a given Canonical Option doesn't affect the behavior of the component and can be removed.

The most obvious case is that neither a memory nor realloc option is needed if

  • the total flat size of its parameters is less than MAX_FLAT_PARAMS,
  • the total flat size of its return values is less than MAX_FLAT_RESULTS,
  • and none of the param or result types transitively include allocating types (e.g. list<T>, string).

A more subtle case that may be too niche but could be considered is detecting that the post-return function has no side effects (likely due to other optimizations) and can be removed.

Redundant Item Elimination

If there are multiple items that are redundant, the redundant copies can be removed.

e.g. two definitions of the same function type

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.