Small Data Optimization

Strings and vectors are so common in Rust code that they can hurt performance in various ways. This talk will cover strategies to improve performance when data is small enough to store on the stack or deduplicate.


- (1 min) Brief introduction of myself.
- (3 min) Discuss various crates for small string/vector optimizations.
 - Why they differ from one another.
 - Benefits: cache locality and less heap usage.
- (20 min) How to implement small data optimization:
 - (5 min) `enum` using no `unsafe`:
  - Demonstrates a core strength of Rust.
 - (12 min) Using `unsafe` to eke out as much performance as possible:
  - Benefits include: no wasted bytes and fine control over mutation strategies, like copy-on-write.
  - Need to be actively aware of all possible cases.
   - Niche optimization (e.g. `Option`) requires special care.
  - Test with MIRI: undefined behavior and endianness.
 - (3 min) Interning.
  - Deduplicating small strings.
  - Local versus global.
- (6 min) Conclusion:
 - "Small" changes meaning based on the context.
 - Rust can provide optimizations seen in C/C++ but it doesn't have to be difficult.
 - Don't need to reach for `unsafe` unless you are bringing something new to the table and have tested all possible cases.
- (10 min) Questions


RustLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".

Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2024 RustLab | The international conference on Rust in Florence-Design & devCantiere Creativo-Made withDatoCMS