Redian新闻
>
Re: Thank you and.Re: a question about lower IO
avatar
Re: Thank you and.Re: a question about lower IO# Unix - 噫吁兮,危乎高哉
n*t
1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is not true.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
why do you need to force it?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The diefference should be trivial.
avatar
p*f
2
of course write() is buffered, the data is buffered in the OS memory.
while with fwrite(), the data is buffered on the user application
level first, then passed to OS via write().
avatar
w*n
3
This , you never know for sure, sometimes yes sometimes no. the system
usually has a daemon process periodcally update the system buffer to
harddisk (i.e. 30 seconds).
you should read about some database application's recovery scheme if
your target is reliable IO -- it is not a simple issue at all.
avatar
p*f
4
fflus() just sends the data to OS buffer, as white(), it does not touch
phisical hard disk.
as wien suggested, some systems are doing background fsync at about 30
sec frequency, if you feel you can't afford 30 second data lost, you
at do a fsync every 10, or 5 or 1 seconds. adjust the intervals to find
the best frquency.
BTW, are you worring about application crash or OS crash, IIRC, the data
in OS buffer will not lost even if your application crashed.
maybe, your concern is data integrity, the
avatar
p*f
5

As I said, you do not have to worry about application crash,
'cause OS buffered data will not lost in such occasions.
fsync() only forces OS level data flush to disk, you have to write()
or fflush() first.
avatar
l*y
6
Actually, I think there is always a conflict between realibility and performance.
you always want to buffer much data enough b4 make a fsync() request, then it
causes the reliablity problem
If you are REALLY serious about this, My suggestion is to use NVRAM (non-
violate RAM) it won't lose any data even when there is a power-off. for further
reading:
http://citeseer.nj.nec.com/hitz95file.html
avatar
n*t
7
this is not a real buy.
Why need to sync it?
you need to focus on what you have surely written.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。