Giter Club home page Giter Club logo

rust-vec-array-perf's Introduction

Rust Vector and Array performance differences

This repository contains sample code showcasing differences in performance occuring on most platforms tested.

Rust follows the philosophy of "zero-cost abstrations", which was introduced with C++ to describe higher-level data structures and algorithms built in the language and its standard library providing the same performance as optimal low-level code.

Code illustrating the issue

The sample code provided in both stable Rust and C++11 implement a typical audio DSP algorithm called digital biquad filter using Direct Form 2 IIR in a textbook way: without SIMD, parallelization other any optimization.

The C++ code is very close to the Rust one. Both generate an identical output. It can be compiled with either GCC or Clang for speed comparison with the Rust code.

In results/ you can find benchmarks of the Rust and C++ implementation compiled for with arm, armv7, aarch64 architectures, GCC and Clang compilers.

Observations

  • The same algoritm working on an Array-backed buffer is usually 20% to 60% faster than with a Vector-backed buffer
  • Two most recently designed CPUs (1 Intel, 1 ARM64) tested perform identically between Array and Vector buffers
  • Only one CPU tested (Intel Core2 Duo) is slower by 10% working on an Array buffer versus Vector
  • The performance gap occurs on 32-bit and 64-bit architectures also x86_64 and ARM processors

Rust compared to C++

  • Rust performance is comparable to C++ overall
  • On the systems exhibiting the Vector/Array perf difference:
    • Rust Vector is slower than GCC C++ Vector
    • Rust Array is faster than GCC C++ Vector
    • Rust Vector is near-identical to Clang C++ Vector

rust-vec-array-perf's People

Contributors

supercurio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.