memorysafety / rav1d

An AV1 decoder in Rust.
BSD 2-Clause "Simplified" License
249 stars 17 forks source link

Add `Copy` to some structs #1332

Open CrazyboyQCD opened 1 month ago

CrazyboyQCD commented 1 month ago

Godbolt Link As you can see in the asm output, even set opt-level = 3, if we don't add Copy to structs with all fields Copy derived, in clone() it generates more mov and large struct can't trigger memcpy, I suggest to add Copy to them to alleviate binary size bloated and performance problem. List of structs that could add Copy (Simple search may miss):

kkysen commented 1 month ago

I didn't realize this happens. Very good catch! We'll definitely look into this. It's a shame rustc optimizes non-Copy types so much worse, though, even when they're otherwise identical.

CrazyboyQCD commented 1 month ago

Opened an issue.