<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I am curious what platform you are build the staff and what is the config?<div>fsync is behind <span class="Apple-style-span" style="font-family: 'times new roman', 'new york', times, serif; font-size: 16px; font-style: italic; ">USE_FSYNC </span>but </div><div><div><br></div><div><div>#ifndef O_SYNC</div><div>#define O_SYNC 0</div><div>#define USE_FSYNC 1</div><div>#endif</div></div><div><br></div><div>- Dmitry</div><div><br><div><div>On Jul 26, 2012, at 3:36 PM, Damienuk Davis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; position: static; z-index: auto; "><div><blockquote type="cite"><div class="yui_3_2_0_19_134328206548091"><div><font size="3">In my project there are fsms that communicates with c via erl driver (port). There are io:fwrite's in the erlang side. This program along works fine. But when you run some other process with high disk access, it causes erlang program to halt even if there is</font> enough memory and processing. If I comment the fsync is run_erl.c file then program works fine even with higher load on hard disk.<span style="font-size: 12pt; "> </span></div></div></blockquote><div><div><span style="font-style: italic;">static void write_to_log(int* lfd, int* log_num, char* buf, int len)</span></div><div><span style="font-style: italic;">{</span></div><div><span style="font-style: italic;"> int size;</span></div><div><span style="font-style: italic;"><br></span></div><div><span style="font-style: italic;"> /* Decide if new logfile needed, and open if so */</span></div><div><span style="font-style: italic;"><br></span></div><div><span style="font-style: italic;"> size = lseek(*lfd,0,SEEK_END);</span></div><div><span style="font-style: italic;"> if(size+len > log_maxsize) {</span></div><div><span style="font-style: italic;"> close(*lfd);</span></div><div><span style="font-style: italic;"> *log_num = next_log(*log_num);</span></div><div><span style="font-style: italic;"> *lfd = open_log(*log_num, O_RDWR|O_CREAT|O_TRUNC|O_SYNC);</span></div><div><span style="font-style: italic;"> }</span></div><div><span style="font-style: italic;"><br></span></div><div><span style="font-style: italic;"> /* Write to log file */</span></div><div><span style="font-style: italic;"><br></span></div><div><span style="font-style: italic;"> if (write_all(*lfd, buf, len) < 0) {</span></div><div><span style="font-style: italic;"> status("Error in writing to log.\n");</span></div><div><span style="font-style: italic;"> }</span></div><div><span style="font-style: italic;"><br></span></div><div><span style="font-style: italic;">#if USE_FSYNC</span></div><div><span style="font-style: italic;"> fsync(*lfd);<span class="Apple-tab-span" style="white-space:pre"> </span><span style="font-weight: bold;">//after commenting this line it works fine</span> </span></div><div><span style="font-style: italic;">#endif</span></div><div><span style="font-style: italic;">}</span></div></div><blockquote type="cite" style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><div class="yui_3_2_0_19_134328206548091" style="font-size: 12pt; "><div style="font-size: 12pt; "><br></div><div style="font-size: 12pt;
"><br></div><div style="font-size: 12pt; ">Thanks</div><div style="font-size: 12pt; ">Damien</div></div></blockquote><div style="font-size: 12pt; "><div class="yui_3_2_0_19_134328206548091" style="font-size: 12pt; "><div style="font-size: 12pt; "><br></div></div></div><div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "><div class="yui_3_2_0_19_134328206548091" style="font-size: 12pt; "><div style="font-size: 12pt; "><br></div></div></div></div> <div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "> <div style="font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "> <div dir="ltr"> <font size="2" face="Arial"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> dmitry kolesnikov <<a href="mailto:dmkolesnikov@gmail.com">dmkolesnikov@gmail.com</a>><br> <b><span style="font-weight: bold;">To:</span></b> Damienuk Davis <<a href="mailto:damienuk@ymail.com">damienuk@ymail.com</a>> <br><b><span style="font-weight:
bold;">Cc:</span></b> "<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>" <<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, July 26, 2012 5:44 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [erlang-questions] run_erl and fsync<br> </font> </div> <br>
<meta http-equiv="x-dns-prefetch-control" content="off"><div id="yiv1178093271"><div><div>Does fsync block any VM scheduler? Or is it executed within async thread?</div><div>Or none of them :-)</div><div><br></div><div>I do not think that flush log is required for majority of Web systems. I believe this is a TeleCo legacy... Should it be configurable at least build time?</div>
<div><br>Best Regards,<div>Dmitry >-|-|-*></div><div><br></div></div><div><br>On 26.7.2012, at 9.10, Damienuk Davis <<a rel="nofollow" ymailto="mailto:damienuk@ymail.com" target="_blank" href="mailto:damienuk@ymail.com">damienuk@ymail.com</a>> wrote:<br><br></div><blockquote type="cite">
<div><div style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255); font-size: 12pt; font-family: 'times new roman', 'new york', times, serif; "><div style="font-size:12pt;">Hi all,</div>
<div style="font-size:12pt;"><br></div><div><div><font face="'times new roman', 'new york', times, serif">In one of my projects I used run_erl to launch Erlang VM in daemon mode, rotate logs, etc.</font></div>
<div><font face="'times new roman', 'new york', times, serif">But I discovered unexpected performance problem running production application with run_erl. Application caused high iowait.</font></div><div><font face="'times new roman', 'new york', times, serif">After some investigation I found that run_erl does fsync on every log entry, causing disk IO load. Do we need fsync on every log entry.</font></div>
<div><font face="'times new roman', 'new york', times,
serif">Appreciate your valuable comments.</font></div></div><div style="font-size:12pt;"><br></div><div style="font-size:12pt;">
Thanks</div><div style="font-size:12pt;">Damien</div></div></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br>
<span>erlang-questions mailing list</span><br><span><a rel="nofollow" ymailto="mailto:erlang-questions@erlang.org" target="_blank" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a></span><br><span><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></span><br>
</div></blockquote></div>
</div><meta http-equiv="x-dns-prefetch-control" content="on"><br><br> </div> </div> </div></div></blockquote></div><br></div></div></body></html>