Debian Codegraph @

/

debian rust-copyless 0.1.5-1debian librust-copyless-dev debian librust-copyless+default-dev debian librust-copyless-0-dev debian librust-copyless-0+default-dev debian librust-copyless-0.1-dev debian librust-copyless-0.1+default-dev debian librust-copyless-0.1.5-dev debian librust-copyless-0.1.5+default-dev cargo copyless 0.1.5 debianjsonmakefilemarkdownrustrust-c-abishelltomlyaml 20 files · 103 symbols
View dependency graph

Depends on

README (full)

copyless

Build Status Crates.io

Rust abstractions can be zero cost in theory, but often reveal quite a few unnecessary memcpy calls in practice. This library provides a number of trait extensions for standard containers that expose API that is more friendly to LLVM optimization passes and doesn't end up with as many copies.

It aims to accelerate WebRender and gfx-rs.

Background

The memcpy instructions showed in profiles of WebRender running in Gecko. @jrmuizel built a tool called memcpy-find that analyzes LLVM IR and spews out the call stacks that end up producing memcpy instructions. We figured out a way to convince the compiler to eliminate the copies. This library attempts to make these ways available to Rust ecosystem, at least until the compiler gets smart enough ;)

Here is a small example

use copyless::BoxHelper;

enum Foo {
    Small(i8),
    Big([f32; 100]),
}

#[inline(never)]
fn foo() -> Box<Foo> {
    Box::new(Foo::Small(4)) // this has 1 memcopy
    //Box::alloc().init(Foo::Small(4)) // this has 0 memcopies
}

fn main() {
    let z = foo();
    println!("{:?}", &*z as *const _);
}

Playground permalink.

dir debian/
dir src/
file .cargo_vcs_info.json
file .gitignore
file .travis.yml
file CHANGELOG.md
file Cargo.toml
file Cargo.toml.orig
file LICENSE-APACHE
file LICENSE-MIT
file README.md
file bors.toml
file rustfmt.toml