<html><body><div style="color:#000; background-color:#fff; font-family:times new roman, new york, times, serif;font-size:12pt"><div><span>It's linux (Redhat ES 5.2) platform with following server configuration</span></div><div><span><span style="font-size: 12pt; ">DL370 with </span>2*6core and 12GB RAM </span></div><div><span>Is it safe to define O_SYNC (this will cause to bybass fsync call)? What can be the impact to the system?</span></div><div><span><br></span></div><div><span><br></span></div><div><br></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 <dmkolesnikov@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> Damienuk Davis <damienuk@ymail.com>
<br><b><span style="font-weight: bold;">Cc:</span></b> "erlang-questions@erlang.org" <erlang-questions@erlang.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, July 26, 2012 8:48 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [erlang-questions] run_erl and fsync<br> </font> </div> <br><div id="yiv534681968"><div>I am curious what platform you are build the staff and what is the config?<div>fsync is behind <span class="yiv534681968Apple-style-span" style="font-size: 16px; font-style: italic; font-family: times, serif; ">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="yiv534681968Apple-interchange-newline"><blockquote type="cite"><div><div style="color: rgb(0, 0, 0);
background-color: rgb(255, 255, 255); font-size: 12pt; font-family: times, serif; "><div><blockquote type="cite"><div class="yiv534681968yui_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="yiv534681968Apple-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-size: 12pt; font-family: times, serif; "><div class="yiv534681968yui_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="yiv534681968yui_3_2_0_19_134328206548091" style="font-size:12pt;"><div style="font-size:12pt;"><br></div></div></div><div style="font-size: 12pt; font-family: times, serif; "><div class="yiv534681968yui_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, serif; "> <div style="font-size: 12pt; font-family: 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 rel="nofollow" ymailto="mailto:dmkolesnikov@gmail.com" target="_blank" href="mailto:dmkolesnikov@gmail.com">dmkolesnikov@gmail.com</a>><br> <b><span style="font-weight:bold;">To:</span></b> Damienuk Davis <<a rel="nofollow"
ymailto="mailto:damienuk@ymail.com" target="_blank" href="mailto:damienuk@ymail.com">damienuk@ymail.com</a>> <br><b><span style="
font-weight:bold;">Cc:</span></b> "<a rel="nofollow" ymailto="mailto:erlang-questions@erlang.org" target="_blank" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>" <<a rel="nofollow" ymailto="mailto:erlang-questions@erlang.org" target="_blank" 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>
<div id="yiv534681968"><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, 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 rel="nofollow" target="_blank" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a></span><br>
</div></blockquote></div>
</div><br><br> </div> </div> </div></div></blockquote></div><br></div></div></div></div><br><br> </div> </div> </div></body></html>