Hacker News new | ask | show | jobs
by Animats 140 days ago
I struggled with this in Wine. "malloc" type memory allocation involves at least two levels of spinlocks. When you do a "realloc", the spinlocks are held during the copying operation. If you use Vec .push in Rust, you do a lot of reallocs. In a heavily multithreaded program, this can knock performance down by more than two orders of magnitude. It's hard to reproduce this with a simple program; it takes a lot of concurrency to hit futex congesion.

Real Windows, and Linux, don't have this problem. Only Wine's "malloc" in a DLL, which does.

Bug reports resulted in finger-pointing and denial.[1] "Unconfirmed", despite showing debugger output.

[1] https://bugs.winehq.org/show_bug.cgi?id=54979

2 comments

Reading the bug report, I don't see any denial. The maintainers are pretty clear that they acknowledge the issue, but don't know how to fix it.
Yes, although it took a while to get there. This confirms the OP's line "Spinning around: Please don't". You can get huge performance hits that are hard to fix. Huge.
Microsoft's rwlock implementation was borked up until sometime last year iirc. this stuff is difficult to do correctly