-
Notifications
You must be signed in to change notification settings - Fork 216
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
Consider inotify integration #39
Comments
+1 |
It's a shame there's no standardised interface for this. I don't like to have different features supported on different platforms (beyond the virtual memory capabilities provided by the OS of course). |
Hi Doug (@hoytech), I’m going to add a couple questions here that all seem related to this. If you want me to separate them out into individual issues I can do that. Q1: When a file is locked and the file is then changed on the disk what does the OS see? The file’s original contents or the updated contents? Q2: What is the overhead in a kill and a restart of vmtouch? Background: I guess we’d need somewhat of a real world example to answer this, which itself brings up a sub-question. You have better documentation than 90% of all projects out there, but as with everything some really complex examples would help. Q2-subA: How would you write the vmtouch command(s) to accomplish this? Goal is to ‘memorize’ just the production websites. Given the directories:
We want to:
My guess is: [1]
That might need to be 2 commands? One each for /var/htdocs/a and /var/htdocs/d? If so, that brings up another sub-question: Q2-subB: What do subsequent vmtouch do to the prior vmtouch commands? Okay, now that we have a possible command(s) to work from is there any real benefit to using Inotify, or something like Best, [1] Edit: Added daemon switch. |
Hey, sorry for the delay! Good questions.
This depends on how the file is modified. If the file is On the other hand, if the file's contents themselves are modified, then the lock will continue to apply to the modified pages of the file. On the other other hand, if a file is appended to the pages that were present in the file originally will continue to be locked but the new appended pages will not be locked.
It depends on how big your directory tree is. Usually the overhead is not that high since after restarting vmtouch it just needs to crawl the directory tree again (similar overhead to running
Wow thanks!
Your command looks reasonable. I would run it with just
I'm not sure exactly what you mean by this? If multiple vmtouch commands lock the same files, the file contents will be locked until both vmtouch commands are killed. In other words, multiple locks can exist on the same file contents.
Good question. I feel like there is not a lot of benefit in inotify and co in most server-side use-cases. The overhead should be fairly small, and it isn't really an intrusive operation. If you have a lot of file modifications going on, and are low on memory for page-cache, then it might be beneficial to get the locks added as quickly as possible, but aside from this extreme situation the principle of time locality should ensure that most of the pages are kept in cache until the next vmtouch "rebuild" as you put it. The one major benefit I would see for inotify would be on power constrained devices like phones. In those cases it might be better to not waste power waking up and rebuilding when nothing has changed in the directory tree. Hope this helps! Doug |
Thanks Doug! To clarify for Q2-subB, I’ll complete the workflow I was thinking would be needed for this use case, taking into account your replies, and make it in the same format your examples page uses. Since this would be run as root, I grabbed an existing root script that handles service restarts, so it has more ‘stuff’ than some will need or want. Not tested, but should be mostly correct ;) [1] Also, I wrote the below for ease of use, as a few extra milliseconds is no big deal, but tens of seconds would be. Which brings up another couple related ‘theoretical performance’ questions.
I’m sure the answer to these are really case specific, so do you have any general guideline(s) or a rule of thumb we can apply? Best, [1] Example 6 Daemonise and lock selected production websites and other desired web server (e.g. Apache) specific files, that are intermixed with non-production websites, into physical memory. Use cron to run the process every 5 minutes while not allowing the script to be run again if it’s still running. Step one Use the verbose switch Step two Create a
Step three Add it to cron.
|
Hey sorry was just going through my backlog and noticed I forgot to reply:
There is a little bit more overhead, but not that much more. As you say it's probably specific to your system so worthwhile benchmarking if you are concerned.
There isn't that much difference between vmtouch's use of mlock/mlockall, except that mlockall will lock a little bit more memory, but will make fewer system calls. Again, probably very minor difference. |
When locking files into memory, we could use inotify (or other interfaces for different OSes) to discover when a file's size or inode changes, and re-map and re-lock the new contents.
See #12 for more discussion on this.
The text was updated successfully, but these errors were encountered: