[erlang-questions] Erlang and fsync

Lukas Larsson lukas@REDACTED
Mon Aug 4 09:46:30 CEST 2014


Hello!

On Fri, Aug 1, 2014 at 4:32 PM, Magnus Ahltorp <map@REDACTED> wrote:

>
> 1) Since directories are not openable with file:open, it is not possible
> to fsync directories. This is a problem, since fsync() doesn't necessarily
> ensure that the directory entry of a newly created file has reached the
> disk.
>

As stated in this thread there is no way to do this cross-platform, so if
you need this functionality and it is available on your OS I would suggest
writing a small nif.

2) fsync() blocks the thread that executes it until the data is submitted
> to the disk. A number of Erlang processes doing fsync() could totally wreck
> the realtime performance of the system, since fsync() can take a long time.
>

If you make sure that you open all the sensitive files with the [raw]
option and have "enough" async threads to deal with the fsyncs that are in
progress then only the Erlang process issuing the command will be blocked.
All other processes will continue running, keeping their realtime
guarantees. If you do not use [raw], or have too few async threads that you
might see queues growing and the overall latency of file operations will
increase. It will however not effect non-file related things.

Also you might want to consider using the [{sync,true}] option to file:open.

Lukas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140804/60bcaa02/attachment.htm>


More information about the erlang-questions mailing list