DevilKing's blog

冷灯看剑,剑上几分功名?炉香无需计苍生,纵一穿烟逝,万丈云埋,孤阳还照古陵

0%

go to rust

原文链接

performance:

  • data structures
  • scale
  • access patterns
  • architecture of the service.

Each Read State has several counters that need to be updated atomically and often reset to 0.

GC问题

After digging through the Go source code, we learned that Go will force a garbage collection run every 2 minutes at minimum. if garbage collection has not run for 2 minutes, regardless of heap growth, go will still force a garbage collection.

Rust is blazingly fast and memory-efficient: with no runtime or garbage collector, it can power performance-critical services, run on embedded devices, and easily integrate with other languages.

It enforces memory rules at compile time, making it virtually impossible to have runtime memory bugs.

The Rust performance optimizations included:

  1. Changing to a BTreeMap instead of a HashMap in the LRU cache to optimize memory usage.
  2. Swapping out the initial metrics library for one that used modern Rust concurrency.
  3. Reducing the number of memory copies we were doing.