Abstract
Outline:
- (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