Skip to content
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

MMAP makes machine swap a lot #383

Open
Scooletz opened this issue Aug 29, 2024 · 4 comments
Open

MMAP makes machine swap a lot #383

Scooletz opened this issue Aug 29, 2024 · 4 comments
Labels
bug Something isn't working operating system OS related issue, that may require intrinsic knowledge of low level OS stuff

Comments

@Scooletz
Copy link
Contributor

Scooletz commented Aug 29, 2024

On Windows, memory mapped file occasionally makes a computer swap a lot and makes Paprika behave terribly ppor. With a lot of memory committed, when the size of the mmaped region breaches the space on system disk, it starts to stall. Investigate this behavior and provide a way to fix it. This happens in a scenario of an import where mmaped file is used without any write or flushes and FlushViewOfAFile is called only at the end to be followed by FlushFileBuffers. Still, according to my understanding system should flush what is needed on it's own so that the swap is not affected.

@Scooletz Scooletz added this to Paprika Aug 29, 2024
@Scooletz Scooletz converted this from a draft issue Aug 29, 2024
@Scooletz Scooletz added operating system OS related issue, that may require intrinsic knowledge of low level OS stuff bug Something isn't working labels Aug 29, 2024
@ssonthal
Copy link
Contributor

ssonthal commented Sep 10, 2024

The first solution that can help here is related to dynamically allocating memory mapped files using NtCreateSection APIs. This will reduce the size of the memory mapped files to be written to disk and saving a lot of RAM.

Secondly, during imports, we can try writing calling FlushViewOfFile and FlushFileBuffers after every 10 MB (size-wise) or 5 seconds (duration-wise) instead of doing it all at the end.

Let me know what you think.

@Scooletz
Copy link
Contributor Author

This could be issue that happens only when there's no Flush. We could test it and disable the mmap option and go with file writes and flush at the end. This requires a repro though and then more testing.

@Scooletz
Copy link
Contributor Author

@damian-orzechowski reports that occasional .FlushForce (MSYNC + FSYNC) decreases the overhead a lot. The call itself though is time consuming. One take could be to run in a background thread when running the Snap Sync and/or Importer

@ssonthal
Copy link
Contributor

This could be issue that happens only when there's no Flush. We could test it and disable the mmap option and go with file writes and flush at the end. This requires a repro though and then more testing.

@Scooletz Can we try this? You can create an issue or a lot of sub-issues for this maybe. And I will try to work part-by-part to remove dependency on mmap and use fsync, read, write instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working operating system OS related issue, that may require intrinsic knowledge of low level OS stuff
Projects
Status: Todo
Development

No branches or pull requests

2 participants