Skip to content

WasmFS: Support non-private mmap #17801

Open

Description

@tlively

The _mmap_js implementation in syscalls.cpp has a TODO:

  // TODO: handle non-private mmaps. Those can be optimized in interesting ways
  //       like avoiding an allocation and a copy as we do below (whereas a
  //       private mmap is always a copy into a new, private region not shared
  //       with anything else).

It also asserts that the flags contain MAP_PRIVATE. We don't need to fully address the optimizations in the TODO yet, but we do need to do better than asserting on MAP_SHARED.

Activity

  1. added this to the WasmFS feature parity milestone on Sep 6, 2022
  2. moved this to Todo in WasmFSon Sep 6, 2022
  3. kripken commented on Sep 6, 2022

    @kripken
    Member

    We could support MAP_SHARED on MemoryFile in the simple case where it is not reallocated. That is basically what we supported in the old JS FS. Anything more would probably be quite hard, though.

    Before working on this I'll try to collect data on how useful the limited form is. I'm not sure it's been used much in the old FS - we've normally recommended people to not use MAP_SHARED at all (and use features we can fully support).

  4. past-due commented on Sep 22, 2022

    @past-due
    Contributor

    It looks like MAP_SHARED is used by __map_file, which is used by musl's gettext / libintl implementation:

    if ((map = __map_file(name, &map_size))) break;

    So it is needed to load message catalogs.

  5. tlively commented on Sep 22, 2022

    @tlively
    MemberAuthor

    Good find, @past-due! It looks like the implementation of __map_file also closes the file descriptor right after mapping, so in the current implementation that ties mappings to fds, there's no way that modifications can make it back to the file.

  6. tlively commented on Feb 2, 2023

    @tlively
    MemberAuthor

    A couple users ran into mmap bugs on #15140.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

  • Status
    Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions