Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
arya dradjica
@bal4e@tech.lgbt  ·  activity timestamp 4 hours ago

Optimizing Rust code is really fun. When something is run millions or billions of times, nanoseconds and individual CPU instructions matter. The best way to do this isn't to write assembly -- it's to put yourself in LLVM's place, understand the kinds of optimizations it wants to perform, and understand what is blocking them. A common case I run into is "LLVM wants to represent (a, b) as (a + b, b), but it's part of a struct so the change has to be performed every time the struct is loaded." LLVM can't change the struct, obviously...

Has anybody tried teaching LLVM data structure optimization? Along the lines of: "Here's a struct with a completely undefined layout and representation, and every single function that can access the struct. Based on the uses, try to memoize common computations by adding new fields, and try removing unused fields." Getting there requires locating all uses of the fields of a struct, but this is possible (at least, quite often) in Rust.

#programming #optimization #llvm

  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login