-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory usage on Windows #239
Comments
Is this really an issue? Did you observe the software actually running out of memory? |
This is an issue, yes it is possible to run out of memory, which is why we switched from memory-mapped I/O at Subspace. In fact Windows will use memory-mapped I/O even for regular file system operations internally unless buffering is explicitly disabled. The core issue is that while that memory is hypothetically reclaimable by the kernel, Windows is spectacularly bad at that. So on one hand it is an issue for a user that they see high (often close to 100%, but not quite 100%) memory usage, on the other hand since Windows placed a bunch of useless crap into memory, apps that actually need memory for something useful start to lag and when Windows is not able to reclaim memory fast enough simply crash outright. It is a bit smaller issue with database due to physical size of it, with multi-TB files we had a really horrible user experience with memory-mapped I/O. But it is still work fixing and moving logic into applicaion domain with proper control over what is stored in memory and for how long. |
Hi, we've been battling memory usage on Windows at Subspace for a while and the gist of it is that Windows is just horribly bad at not using huge amounts of memory with memory-mapped files or any other files that don't disable buffering completely (I don't think #235 has a major impact).
I tried to convince Windows developers that it makes no sense, but they remain unshakable, see discussion at rust-lang/rust#122473
TL;DR: To get controllable memory usage on Windows the only solution is to throw Windows kernel's file system "smartness" out of the window to the maximum extent possible with
FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING
and do direct reads manually. I wrote a wrapper for this purpose that I think may deserve to become a library.The text was updated successfully, but these errors were encountered: