3 ms·
What about calling mmap to map /etc/localtime into memory? The file would still have to be parsed for every call to localtime(), but the system call is avoided
by curlypaul924 10y ago
What about calling mmap to map /etc/localtime into memory? The file would still have to be parsed for every call to localtime(), but the system call is avoided.
(Better yet, if it were possible to memory-map the directory entry for /etc/localtime, parsing could be avoided as well).
I agree the best solution is to provide a more sensible API. Why should an application be limited to only _one_ timezone?
- geofft 10y agoI think I like that solution! It doesn't work if someone replaces /etc/localtime with a new file, but it works if they update it in place. It's low-overhead as long as /etc/localtime remains in cache; the process that updates it will write to the same pages. It's pretty high-overhead if /etc/localtime ever gets flushed from cache, though, since you have to go out to disk.
- cbsmith 10y agommapping doesn't solve the problem unless the file was edited in place (rather than overwritten as is commonly done). You'll just have an mmap on an inode that is no longer visible in the directory.