Re:Appending to an std:string character-by-character: how do...
by nynx on Thursday October 26, 2023 @11:14PM
(#38034318)
That’s a bug in the allocator. Realloc should not grab a lock the entire time.
Re:Appending to an std:string character-by-character: how do...
by Animats on Friday October 27, 2023 @02:46PM
(#38042337)
It's complicated. There are three nested locks. I could see snapshots of what was happening in gdb, but don't fully understand the dynamics.
The effect was that a game-type program dropped from 60FPS to 0.5 FPS.
Re:Appending to an std:string character-by-character: how do...
by hawk_ on Thursday October 26, 2023 @11:45PM
(#38034469)
Surely that must be a specific allocator. Does rust allow you to use say jemalloc or alternatives? Or are you saying this lock is acquired no matter which allocator is used?
Re:Appending to an std:string character-by-character: how do...
by connicpu on Thursday October 26, 2023 @11:59PM
(#38034536)
Yeah you can override the global allocator pretty easily[1]. But the default uses the system allocator, and I guess it sounds like Wine's is pretty bad
[1]: https://doc.rust-lang.org/std/alloc/index.html#the-global_al...
Re:Appending to an std:string character-by-character: how do...
by Animats on Friday October 27, 2023 @02:30AM
(#38035332)
It's in the DLL that Wine uses to emulate Windows. Not in the Rust library.
Bug report: [1]
Down at the bottom, this grows by resizing an allocation. Ordinarily, that's cheap. But if you're resizing a reasonably sized array, at least under Wine it's a copy of the array with the lock on the memory allocator set. There's a spinlock involved. If many threads are allocating, futex congestion is possible and speed drops by two orders of magnitude. Ouch.