{"id":14,"date":"2022-08-06T22:08:42","date_gmt":"2022-08-06T20:08:42","guid":{"rendered":"http:\/\/cbleile.de\/wordpress\/?p=14"},"modified":"2023-02-05T22:10:42","modified_gmt":"2023-02-05T21:10:42","slug":"running-intel-x86-64-vms-with-an-oracle-db-on-apple-silicon-arm","status":"publish","type":"post","link":"http:\/\/cbleile.de\/wordpress\/running-intel-x86-64-vms-with-an-oracle-db-on-apple-silicon-arm\/","title":{"rendered":"Running Intel x86-64 VMs with an Oracle DB on Apple Silicon (ARM)"},"content":{"rendered":"\n<p>For testing purposes many IT-people traditionally use Virtual Machines (VMs) on their Laptops (often on Oracle Virtualbox). Since Apple moved to its own processor type (Apple Silicon, i.e. ARM architecture), it&#8217;s no longer possible to run VMs based on Intel x86-64 on Apple ARM (e.g. on Apple MacBook Pros with M1 or M2 processors). I.e. as the Oracle Database does not run on ARM, a workaround is necessary for e.g. a Consultant with an Apple Laptop to be able to run tests against Oracle databases on that Laptop.<\/p>\n\n\n\n<p>REMARK: Oracle announced to port the DB software to ARM in the future. See e.g. <a href=\"https:\/\/youtu.be\/m9vhjnzYa7I\">this video<\/a> at 26:40 &#8211; 27:22.<\/p>\n\n\n\n<p>What are the alternatives?<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>runinng the DB-server VM on the Cloud (requires access to the cloud resources over the internet)<\/li>\n\n\n\n<li>running the DB-server on separate hardware (requires access to separate hardware. So you need to carry the hardware with you or provide remote access to it, e.g. over VPN)<\/li>\n<\/ul>\n\n\n\n<p>Another potential alternative would be the emulation of x86-64 on ARM. I.e. on Mac that means running QEMU. The product UTM makes that easy as it adds a GUI on top of QEMU.<\/p>\n\n\n\n<p>According lots of feedback on the internet the emulation is <strong>VERY SLOW<\/strong>. I thought I&#8217;ll check that myself on what &#8222;very slow&#8220; means in terms of running an Oracle database in an emulated environment.<\/p>\n\n\n\n<p>Here&#8217;s the environment I&#8217;m in:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>MacBook Air (M1, 2020), 8GB RAM<\/li>\n\n\n\n<li>UTM version 3.2.4. from Turing Software LLC (can be downloaded from the App Store) and costs $10<\/li>\n<\/ul>\n\n\n\n<p>For testing purposes I created 2 VMs:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ubuntu Linux with Oracle XE on Docker<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/UTM-Docker.png\" alt=\"\" class=\"wp-image-18329\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Oracle Linux 8.x with Oracle EE 19.16.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/UTM-2-1024x752.png\" alt=\"\" class=\"wp-image-18325\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/UTM-3-1024x386.png\" alt=\"\" class=\"wp-image-18326\"\/><\/figure>\n\n\n\n<p>First of all the good news is that I could install and run the 2 environments without any crash. Everything runs very stable as long as the UTM System setting &#8222;Force Multicore&#8220; is not enabled. In that case UTM can only use 1 core of the Mac. That&#8217;s very stable. With &#8222;Force Multicore&#8220; enabled more than 1 Core can be used from the Mac on the VM. In my case that was fast, but running Java in the VM did not work anymore. I had to disable cores then to make Java work (see the summary below on how I did that).<\/p>\n\n\n\n<p>Now to the main question: What is the performance of the DB-server running in the emulated UTM-VM?<\/p>\n\n\n\n<p>It takes considerable more time to install the environment and it of course feels much slower than running a type 2 hypervisor (like Virtualbox on native x86_64). But I wanted to know exact numbers, so I did a couple of tests:<\/p>\n\n\n\n<p>1.) Running datapatch against a CDB with 1 PDB (part of dbca after installing 19.16. software only):<\/p>\n\n\n\n<p>This test was performed with &#8222;Force Multicore&#8220; disabled.<\/p>\n\n\n\n<p>1 Core for the VM on the emulated environment:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Patch CDB: 2h, 37min, 23sec<\/li>\n\n\n\n<li>Patch PDB$SEED and PDB1: 1h, 41min, 30sec<\/li>\n<\/ul>\n\n\n\n<p>I did run the same on a virtualbox on a MacBook Pro with a 2.6 GHZ Core i7:<\/p>\n\n\n\n<p>2 Cores for VM on type 2 hypervisor on native x86_64:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Patch CDB: 8min, 15sec<\/li>\n\n\n\n<li>Patch PDB$SEED and PDB1: 5min, 32sec<\/li>\n<\/ul>\n\n\n\n<p>Result: Emulated VM with half the cores is approx factor 18 slower than on the native machine.<\/p>\n\n\n\n<p>REMARK: All tests performed for this Blog were done on those 2 machines (MacBook Air 2020 M1 with emulated UTM-VM versus MacBook Pro 2019 Intel with Virtualbox).<\/p>\n\n\n\n<p>2.) A pure DB-CPU-Load test<\/p>\n\n\n\n<p>To utilize a DB sever on CPU I usually run the following cpu_load.sql-script in sqlplus:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>set lines 120\nset timing on time on\nwith t as ( select rownum from dual connect by level &lt;= 60)\nselect \/*+ ALL_ROWS *\/ count(*) from t,t,t,t,t\n\/<\/code><\/pre>\n\n\n\n<p>I.e. the dedicated server process runs 100% on CPU for a couple of secs. This is a single thread performance test and is not related to the number of active cores as the test runs on 1 core only. The results were:<\/p>\n\n\n\n<p>UTM (emulated): 3min, 33sec<br>Virtualbox (native): 15.5 secs<\/p>\n\n\n\n<p>&#8211;&gt; The emulated VM is 13.75 times slower<\/p>\n\n\n\n<p>3.) CPUSPEED in the Oracle system statistics<\/p>\n\n\n\n<p>The CPUSPEED of system stats in aux_stats$ shows 342 for that emulated machine (342 millions of instructions per second). I gathered system statistics while running a swingbench test:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/system-stats-charbench-1024x485.png\" alt=\"\" class=\"wp-image-18344\"\/><\/figure>\n\n\n\n<p>The performance cores of the M1 run between 600 &#8211; 3204 MHz. I.e. the emulated environment is approximately 3204\/342 = 9.4 times slower from an Oracle perspective.<\/p>\n\n\n\n<p>4.) Swingbench<\/p>\n\n\n\n<p>Loaded Swingbench data with the oewizard by leaving everything on default except the load factor and the parallelism. I took a load factor 0.7 and a parallelism of 2. The total runtime for the load was 17min, 52secs and it inserted 14&#8217;569 rows \/sec:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/oewizard-utm-812x1024.png\" alt=\"\" class=\"wp-image-18345\" width=\"602\" height=\"759\"\/><\/figure>\n\n\n\n<p>Doing the same against Virtualbox on a native Intel environment looked as follows:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/oewizard-load-time-Intel.png\" alt=\"\" class=\"wp-image-18333\"\/><\/figure>\n\n\n\n<p>I.e. 14569 rows inserted per second on the emulated environment compared to 75966 rows per second on Virtualbox (factor 5.2). But as I just ran with a parallelism of 2, I probably haven&#8217;t used the available resources effectively.<\/p>\n\n\n\n<p>Running charbench for 1 min on the emulated environment with 8 Users (the number of 8 sessions brought the best TPS-rate) showed approx 55 TPS (on the 2 cores configured VM with &#8222;Force Multicore&#8220;):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/charbench-1min-force-multi-UTM-1024x362.png\" alt=\"\" class=\"wp-image-18346\"\/><\/figure>\n\n\n\n<p>On the native Intel environment configured with 2 cores as well I could achieve 770 TPS with 55 sessions:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/swingbench-1min-Intel-770tps-1024x331.png\" alt=\"\" class=\"wp-image-18337\"\/><\/figure>\n\n\n\n<p>So that&#8217;s a factor of 14 higher TPS on a 2 cores VM.<\/p>\n\n\n\n<p><strong>Summary:<\/strong> It&#8217;s possible to run an Oracle DB in a VM on an Apple Silicon machine, but you have to use hardware emulation, which makes the processing on the DB slower by a factor of 10 &#8211; 14 compared to a Type 2 hypervisor (e.g. Virtualbox). This is OK for doing functional tests, but is usually too slow for heavy testcases or regular installations or upgrades. For best performance enable &#8222;Force Multicore&#8220;, but then Java did not work anymore in my tests (e.g. a command &#8222;$ORACLE_HOME\/OPatch\/opatch lspatches&#8220; did not finish). To workaround the Java issue I disabled all cores except 1, ran the Java program and enabled all cores again. E.g. on a VM with 2 cores enabled (cpu0 and cpu1):<\/p>\n\n\n\n<p>Disable cpu1 as root temporarily:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># echo 0 &gt; \/sys\/devices\/system\/cpu\/cpu1\/online<\/code><\/pre>\n\n\n\n<p>Run your Java program:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;oracle@utm-ora8 ~] $ORACLE_HOME\/OPatch\/opatch lspatches<\/code><\/pre>\n\n\n\n<p>Enable cpu1 as root again:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># echo 1 &gt; \/sys\/devices\/system\/cpu\/cpu1\/online<\/code><\/pre>\n\n\n\n<p>The DB itself was not affected negatively during my tests with &#8222;Force Multicore&#8220; enabled. I do recommend to use &#8222;Force Multicore&#8220; enabled as it makes a huge difference:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/08\/force-multicore-2-1024x754.png\" alt=\"\" class=\"wp-image-18348\"\/><\/figure>\n\n\n\n<p>REMARK: After writing this Blog I detected another potential alternative to run an Oracle DB on ARM. In <a href=\"https:\/\/youtu.be\/GJyCY3F0mmI\">this video<\/a> the possibility is shown to run Windows for ARM in Parallels (could probably be run on UTM as well). You can install &#8222;Oracle for Windows x86-64&#8220; in Windows ARM. The OS will detect the x86-64 code and emulate x86-64 automatically.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For testing purposes many IT-people traditionally use Virtual Machines (VMs) on their Laptops (often on Oracle Virtualbox). Since Apple moved to its own processor type (Apple Silicon, i.e. ARM architecture), it&#8217;s no longer possible to run VMs based on Intel x86-64 on Apple ARM (e.g. on Apple MacBook Pros with M1 or M2 processors). I.e. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[15,13,14,3],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-oracle","tag-apple-silicon","tag-arm","tag-database","tag-oracle"],"_links":{"self":[{"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/comments?post=14"}],"version-history":[{"count":1,"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":15,"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/posts\/14\/revisions\/15"}],"wp:attachment":[{"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/media?parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/categories?post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cbleile.de\/wordpress\/wp-json\/wp\/v2\/tags?post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}