• Stars
    star
    281
  • Rank 147,023 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[deprecated] Avoid memcpy calls when working with standard containers

copyless

Build Status Crates.io

NOTE: crate is marked as DEPRECATED because of #22

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.

More Repositories

1

blade

Sharp and simple graphics library
Rust
479
star
2

vange-rs

Rusty Vangers clone
Rust
428
star
3

froggy

Component Graph System experiment
Rust
297
star
4

mint

Math Interoperability Types
Rust
226
star
5

baryon

Fast prototyping 3D engine
Rust
74
star
6

claymore

Just another tactical RPG in dark fantasy setting
Rust
53
star
7

yasteroids

Yet another Asteroids clone
Rust
52
star
8

choir

Task Orchestration Framework
Rust
46
star
9

wasm-triangle

Rust+GL+WASM triangle sample
Rust
42
star
10

webgpu-servo

WebGPU prototope in Servo browser
35
star
11

pegasus

[DEPRECATED] GFX + Specs framework that lets you fly
Rust
33
star
12

obj

Basic Wavefront OBJ loader
Rust
29
star
13

dotfiles

Configuration for systems I use
Nix
26
star
14

slides

Slides and source material used for presentations
HTML
17
star
15

binary-space-partition

Abstract BSP tree in Rust
Rust
13
star
16

simplecs

Simple Entity-Component System
Rust
11
star
17

wgpu-bench

WebGPU-native benchmark
Rust
11
star
18

ticketed_lock

Ticketed lock synchronization primitive
Rust
11
star
19

dark

Practical BWT-based compressor
Rust
10
star
20

rs-voir

Reservoir logic for understanding spatio/tempral resampling
Rust
8
star
21

shader-translation-benchmark

Benchmarking tools for shader translation
GLSL
7
star
22

scene-rs

[obsolete] Experiments in higher-level code on top of gfx-rs
Rust
7
star
23

graphics

Mind Map of Graphics
7
star
24

synqueue

Yet another MPMC queue
Rust
6
star
25

webgpu-debate

Reconstructions of important debates in WebGPU
HTML
6
star
26

syncell

Sync alternative to RefCell
Rust
6
star
27

WebGLNext-Comparison

Unofficial comparison of WebGL-Next proposals
5
star
28

grid-rs

Generalized grids in Rust
Rust
4
star
29

gfx_kiss

[DEPRECATED] Simple drawing API for gfx-rs
Rust
3
star
30

dark-archon

[old] Fast BWT-based compressor
C
3
star
31

shotgun

Simple game with Baryon
Rust
3
star
32

Framework-Linux

Issues related to Framework laptop on Linux
3
star
33

kvark.github.io

Tinkering log source
SCSS
2
star
34

vulkan-buster

Collection of Vulkan bug tests
Rust
2
star
35

bitflags-serial

Nicely serialized bitflags
Rust
2
star
36

fps-stat

Frame time number crunching
Rust
2
star
37

kri

[old] Modern OpenGL-3 engine, a playground for experimental design concepts and features
Boo
2
star
38

presto-stats

Presto CSV reports analyzer
Rust
2
star
39

gl-bench

Simple fill-rate benchmark in GL
Rust
2
star
40

chaos

Rust
1
star
41

sublime-wgsl

WGSL syntax package for Sublime Text
1
star
42

image-aa-metric

Image anti-aliasing quality metrics
Rust
1
star
43

gl-buster

Simple test app for reproducing GL driver bugs
Rust
1
star
44

gfxbench-test

Test results of gfxbench for API comparison
1
star
45

gfx_pipeline

Rendering pipelines for gfx_scene
Rust
1
star
46

learnet

Just learning code in NN
Rust
1
star