<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kiet Nguyen</title>
    <description>The latest articles on DEV Community by Kiet Nguyen (@kietnguyen).</description>
    <link>https://dev.to/kietnguyen</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F614816%2F65a018f0-e0a8-4b20-beb9-ba9ced4c266f.png</url>
      <title>DEV Community: Kiet Nguyen</title>
      <link>https://dev.to/kietnguyen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kietnguyen"/>
    <language>en</language>
    <item>
      <title>docker-sync performance in Apple M1</title>
      <dc:creator>Kiet Nguyen</dc:creator>
      <pubDate>Mon, 20 Jun 2022 09:16:30 +0000</pubDate>
      <link>https://dev.to/kietnguyen/docker-sync-performance-in-apple-m1-212p</link>
      <guid>https://dev.to/kietnguyen/docker-sync-performance-in-apple-m1-212p</guid>
      <description>&lt;p&gt;Syncing by &lt;code&gt;docker-sync&lt;/code&gt; is still faster than running by native (out of the box)&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Hardware
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Apple M1 Pro&lt;/li&gt;
&lt;li&gt;32GB&lt;/li&gt;
&lt;li&gt;Monterey&lt;/li&gt;
&lt;li&gt;"Enable VirtioFS accelerated directory sharing" experimental feature is checked&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Docker for Mac (only)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Version: 4.9.1 (81317)&lt;/li&gt;
&lt;li&gt;Memory: 8GB&lt;/li&gt;
&lt;li&gt;CPUs: 5&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Native
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it -v /tmp:/var/www alpine time dd if=/dev/zero of=/var/www/test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
real    0m 9.31s
user    0m 0.25s
sys     0m 3.91s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Docker-sync - Strategy: native_osx
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/EugenMayer/docker-sync-boilerplate
cd docker-sync-boilerplate/default
# Set a custom image in docker-sync.yml
#    appcode-native-osx-sync:
# +    native_osx_image: eugenmayer/unison:2.51.3-4.12.0-ARM64
docker-sync-stack start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it default-app-native-osx-1 time dd if=/dev/zero of=/var/www/test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
real    0m 0.35s
user    0m 0.03s
sys     0m 0.31s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Docker-Sync - Strategy: Unison
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/EugenMayer/docker-sync-boilerplate
cd docker-sync-boilerplate/unison
# Set a custom image in docker-sync.yml
#    appcode-unison-sync: # tip: add -sync and you keep consistent names as a convention
#      src: './app'
#      sync_strategy: 'unison'
# +    unison_image: eugenmayer/unison:2.51.3-4.12.0-ARM64
docker-sync-stack start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it unison-app-unison-1 time dd if=/dev/zero of=/var/www/test.dat bs=1024 count=100000
100000+0 records in
100000+0 records out
real    0m 0.31s
user    0m 0.03s
sys     0m 0.28s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docker-sync.readthedocs.io/en/latest/miscellaneous/performance.html"&gt;Performance — docker-sync 0.5.11 documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docker-sync.readthedocs.io/en/latest/getting-started/configuration.html#sync-strategy-image"&gt;_image Configuration — docker-sync 0.5.11 documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>m1</category>
      <category>arm</category>
      <category>docker</category>
    </item>
    <item>
      <title>wkhtmltoimage-binary and wkhtmltopdf-binary gems for ARM</title>
      <dc:creator>Kiet Nguyen</dc:creator>
      <pubDate>Thu, 16 Jun 2022 13:13:58 +0000</pubDate>
      <link>https://dev.to/kietnguyen/wkhtmltoimage-binary-and-wkhtmltopdf-binary-gems-for-arm-2an5</link>
      <guid>https://dev.to/kietnguyen/wkhtmltoimage-binary-and-wkhtmltopdf-binary-gems-for-arm-2an5</guid>
      <description>&lt;h2&gt;
  
  
  Issue
&lt;/h2&gt;

&lt;p&gt;Error below might occur when you have &lt;a href="https://github.com/nicholasklick/wkhtmltoimage-binary"&gt;wkhtmltoimage-binary&lt;/a&gt; or &lt;a href="https://github.com/zakird/wkhtmltopdf_binary_gem"&gt;wkhtmltopdf-binary&lt;/a&gt; gems while running ARM when Gemfile&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Workaround
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install OS dependencies&lt;/li&gt;
&lt;li&gt;Download and install package from &lt;a href="https://wkhtmltopdf.org/downloads.html"&gt;https://wkhtmltopdf.org/downloads.html&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Remove above gem(s) from Gemfile
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# ubuntu:20.04
export PLATFORM=$(dpkg --print-architecture)\
  &amp;amp;&amp;amp; apt-get update\
  &amp;amp;&amp;amp; apt-get install -y libfontenc1 xfonts-75dpi xfonts-base xfonts-encodings xfonts-utils\
  &amp;amp;&amp;amp; wget --quiet https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_${PLATFORM}.deb\
  &amp;amp;&amp;amp; dpkg -i wkhtmltox_0.12.6-1.focal_${PLATFORM}.deb\
  &amp;amp;&amp;amp; rm wkhtmltox_0.12.6-1.focal_${PLATFORM}.deb
  &amp;amp;&amp;amp; rm -rf /var/lib/apt/lists/*\
  &amp;amp;&amp;amp; apt-get purge --auto-remove\
  &amp;amp;&amp;amp; apt-get clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>rails</category>
      <category>arm</category>
      <category>m1</category>
    </item>
    <item>
      <title>Get max memory size of V8</title>
      <dc:creator>Kiet Nguyen</dc:creator>
      <pubDate>Fri, 10 Jun 2022 04:02:19 +0000</pubDate>
      <link>https://dev.to/kietnguyen/get-max-memory-size-of-v8-2o3n</link>
      <guid>https://dev.to/kietnguyen/get-max-memory-size-of-v8-2o3n</guid>
      <description>&lt;p&gt;The default max memory size of V8 is 2GB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ node

&amp;gt; v8.getHeapStatistics()
{
  ....
  heap_size_limit: 2197815296,
  ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2197815296 is 2GB in bytes. When set &lt;code&gt;NODE_OPTIONS=--max_old_space_size=8192&lt;/code&gt;, &lt;code&gt;heap_size_limit&lt;/code&gt; will be 8G or 8640266240 bytes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ NODE_OPTIONS=--max_old_space_size=8192 node

&amp;gt; v8.getHeapStatistics()
{
  ....
  heap_size_limit: 8640266240,
  ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/48387040/how-do-i-determine-the-correct-max-old-space-size-for-node-js#answer-63495296"&gt;How do I determine the correct "max-old-space-size" for node.js?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes"&gt;V8 option: --max-old-space-size=SIZE&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tip</category>
      <category>node</category>
    </item>
  </channel>
</rss>
