Should small Rust structs be passed by-copy or by-borrow? (2019)
forrestthewoods.com
Should small Rust structs be passed by-copy or by-borrow? (2019)
1–10 of 238 posts
Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#2Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#3Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#4Anyway, assuming it's not inlined I would guess pass-by-copy, maybe with an occasional exception in code with heavy register pressure.
Edit: Actually since it's a structure, the calling convention is to memory allocate it and pass a pointer, doh. So it should actually compile the same.
Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#5My first thought was "now what is the calling convention for float parameters again? they are passed in registers right? the compiler can probably arrange so they don't have to actually be copied" and then I realized it will probably even inline it. Anyway, assuming it's not inlined I would guess pass-by-copy, maybe with an occasional exception in code with heavy register pressure. Edit: Actually since it's a structu…
Depending on calling convention, the structure may be spread out into registers.
Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#6Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#7It is a problem of statistics and depends on internals of underlying operating system. I’m not sure you really need that sort of optimisation
Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#8It is a problem of statistics and depends on internals of underlying operating system. I’m not sure you really need that sort of optimisation
What does this have to do with the operating system? There are no syscalls in the code measured here.
Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#9It is a problem of statistics and depends on internals of underlying operating system. I’m not sure you really need that sort of optimisation
What does this have to do with the operating system? There are no syscalls in the code measured here.
Re: Should small Rust structs be passed by-copy or by-borrow? (2019)
#10The other question I have is which style should you use when writing a library? It's obviously not possible to benchmark all the software that will call your library but you still want to consider readability, performance as well as other factors such as common convention.