-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Serialization] Load swiftmodule files as volatile to avoid mmap #33001
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
Conversation
|
@swift-ci Please smoke test |
Avoid mmaping swiftmodule files to hopefully fix issues seen when building many Swift projects in parallel on NFS. This only affects loading ModuleFile, it doesn't affect scanning swiftmodule for dependecies which are still handled as non-volatile. rdar://63755989
15a797b to
a4becda
Compare
|
@swift-ci Please smoke test |
|
Could you elaborate more about what kind of issues in parallel building could potentially be resolved by avoiding mmaping swiftmodule file? |
|
Right, I believe the issue here is that swiftmodule files are being changed by a different process while they are mmaped. The precise behavior of mmap when the underlying file changes is unspecified AFAICT. This setting in LLVM mentions specifically issues on NFS and it could be an important factor here as we don't see this issue on engineers' desks. And in practice, there may be three scenarios where the swiftmodule files can change while it's being read:
|
|
This would explain failures that show up as deserialization errors without an explanation which indicates that it's a memory consistency issue: (An expected deserialization error would have an explanation between those two lines.) And low-level failures in LLVM bitstream code from reading unexpected values, and segfaults when using values from the swiftmodule files for index access. |
|
OK. Though I'm not entirely convinced using mmap really caused these deserialization errors, it's worth experimenting by landing this change. Could you add the rationals as comments and file a radar to revert this change if similar deserialization errors still happen? |
|
@swift-ci Please smoke test |
|
@nkcsgexi Done! |
nkcsgexi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Avoid mmaping swiftmodule files to hopefully fix issues seen when building Swift projects in parallel on NFS. This change only affects loading ModuleFile, it doesn't affect scanning swiftmodule for dependencies which are still handled as non-volatile.
Let's try always avoid mmap at first to confirm if this was the issue. However, this will likely affect memory usage so we may need a way to restrict this further if it causes issues on memory-constrained systems.