Reading mtime (stat) to microsecond accuracy

I tried using

  • File.state(“some/file”)

and discovered that it truncates the timestamps to the nearest second. It seems to be a wrapper for the underlying erlang call:

  • :file.read_file_info(‘some/file’, [{:time, :posix}])

..which returns times in whole seconds…

Any suggestions on how to most performantly access mtimes to maximum accuracy of the filesystem?

Equivalently, the use is debouncing reads of a small JSON file, so a possible workaround is a high speed way to checksum the file? Suggestions?

(The file is small, we have a problem (insert reasons) that means we need to acquire an expensive lock (100s of milliseconds) before reading it, so I need robust way to detect if it’s been changed since last read. Yes, long term we can work on improving the speed of locking, but…)