<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Performance on Bitecode blog</title><link>https://bitecode.blog/categories/performance/</link><description>Recent content in Performance on Bitecode blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 02 Jun 2016 00:00:00 +0000</lastBuildDate><atom:link href="https://bitecode.blog/categories/performance/index.xml" rel="self" type="application/rss+xml"/><item><title>Dumping large MySQL database</title><link>https://bitecode.blog/2016/05/14/mysql-dump-large-database/</link><pubDate>Thu, 02 Jun 2016 00:00:00 +0000</pubDate><guid>https://bitecode.blog/2016/05/14/mysql-dump-large-database/</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;Not going into details of credentials basic mysqldump command looks like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysqldump database &amp;gt; database_dump.sql
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Dump file size was ~3GB which might take quite long. Especially when the connection to mysql server was not fast enough.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;After a few attempts and noticing that it might take too long to fetch all data I found out that there is a nice switch in mysql and mysqldump commands.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--compress, -C
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Switch will tell mysql server to compress the dump on the fly so you can save a lot of bandwidth. However both sides needs to support the setting. Note that you may also use that switch with mysql command.&lt;/p&gt;</description></item><item><title>Log Levels Performance</title><link>https://bitecode.blog/2016/05/14/log-levels-performance/</link><pubDate>Sat, 14 May 2016 00:00:00 +0000</pubDate><guid>https://bitecode.blog/2016/05/14/log-levels-performance/</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;Take an example with grails log.debug() call. Let’s say I want to log a very often executed code.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"&gt;&lt;code class="language-groovy" data-lang="groovy"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Long sum &lt;span style="color:#ff79c6"&gt;=&lt;/span&gt; &lt;span style="color:#bd93f9"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff79c6"&gt;(&lt;/span&gt;&lt;span style="color:#bd93f9"&gt;1&lt;/span&gt;&lt;span style="color:#ff79c6"&gt;..&lt;/span&gt;&lt;span style="color:#bd93f9"&gt;1000&lt;/span&gt;&lt;span style="color:#ff79c6"&gt;).&lt;/span&gt;&lt;span style="color:#50fa7b"&gt;each&lt;/span&gt; &lt;span style="color:#ff79c6"&gt;{&lt;/span&gt; number &lt;span style="color:#ff79c6"&gt;-&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ff79c6"&gt;++&lt;/span&gt;sum
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; log&lt;span style="color:#ff79c6"&gt;.&lt;/span&gt;&lt;span style="color:#50fa7b"&gt;debug&lt;/span&gt; &lt;span style="color:#f1fa8c"&gt;&amp;#34;Sum = ${sum}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ff79c6"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I use log.debug so my information is logged only if my project configuration allows that. That way if we turn off DEBUG, the logged line should not affect application speed. But is that really true?&lt;/p&gt;
&lt;p&gt;Let’s check if the logged value is really not accessed?
To do so we need to turn off DEBUG and modify the code:&lt;/p&gt;</description></item></channel></rss>