Skip to content

Conversation

@ghuls
Copy link

@ghuls ghuls commented May 4, 2022

Use mlock2() instead of mlock() on Linux:

  • mlock2() allows a third argument MLOCK_ONFAULT, which allow to
    lock the pages in a range before touching them, so mlock2()
    can be called before touching all pages instead of after.
  • "vmtouch -t -l" some_file would not keep the pages in cache
    after touching them, so at the lock() step they needed to
    be read again from disk. After this patch files are cached
    twice as fast on this system.

Use mlockall(MCL_FUTURE) instead of mlockall(MCL_CURRENT):

  • Set mlockall(MCL_FUTURE) before touching pages to have similar
    behaviour as the mlock2() approach above.

vmtouch.c Outdated
printf(" -t touch pages into memory\n");
printf(" -e evict pages from memory\n");
printf(" -l lock pages in physical memory with mlock(2)\n");
printf(" -l lock pages in physical memory with mlock(2) or mlock2(2)\n");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using ifndef her too? that way the usage help would clearly show which one it is using.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dope really needed this!

Use mlock2() instead of mlock() on Linux:
  - mlock2() allows a third argument MLOCK_ONFAULT, which allow to
    lock the pages in a range before touching them, so mlock2()
    can be called before touching all pages instead of after.
  - "vmtouch -t -l" some_file would not keep the pages in cache
    after touching them, so at the lock() step they needed to
    be read again from disk. After this patch files are cached
    twice as fast on this system.

Use mlockall(MCL_FUTURE) instead of mlockall(MCL_CURRENT):
  - Set mlockall(MCL_FUTURE) before touching pages to have similar
    behaviour as the mlock2() approach above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants