Slowdown on MacOS

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Mike at Bookup
Posts: 11
Joined: Fri 25 Sep 2015 14:02

Slowdown on MacOS

Post by Mike at Bookup » Wed 07 Oct 2015 14:32

My app gets 5,988 transactions per second on my Mac. Not bad but...

The same app gets 13,927 transactions per second inside a Windows 10 VM - inside that same Mac.

Why would the native MacOS app run at half the speed of the same app for Windows in a virtual machine? I'd expect the emulated Windows 10 to be the slower OS.

Delphi XE7 source for the test app is here:
https://chessopeningsoftware.s3.amazona ... Test01.zip

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Slowdown on MacOS

Post by MaximG » Fri 09 Oct 2015 09:16

The difference in performance while working with SQLite database on different platforms is quite explainable. Ultimately, performance of database interaction is limited by the speed of disk operations. Thus, the in-out subsystem implementation differs on every platform.

Mike at Bookup
Posts: 11
Joined: Fri 25 Sep 2015 14:02

Re: Slowdown on MacOS

Post by Mike at Bookup » Fri 09 Oct 2015 22:26

I do understand that there are differences in SQLite database performance on different platforms. It is always limited by the speed of disk operations.

I am interested in maximum performance on Mac OS.

So I am still puzzled because in this case it is the same OS on the same hard drive. To improve SQLite performance on a Macintosh from 5,988 transactions per second to 13,927 transactions per second on that Mac, all I need to do is... add a VM with Windows in it and run the Windows version of my FireUI app.

That sounds nuts. Adding a VM with Windows on top of OS X can only add overhead - to the same hard drive.

Can you imagine me recommending that solution to my Macintosh customers? To more than double the performance?

My customers are used to 20,000 transactions per second on regular Windows machines.

Increased performance on Mac OS is the reason I purchased LiteDAC.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Slowdown on MacOS

Post by MaximG » Mon 12 Oct 2015 14:05

To increase performance when using SQLite, you can use the following PRAGMA statements:

PRAGMA synchronous = 0 (2 by default) – detailed description:
http://sqlite.org/pragma.html#pragma_synchronous
PRAGMA journal_mode = OFF (DELETE by default) – detailed description:
http://sqlite.org/pragma.html#pragma_journal_mode
PRAGMA temp_store = 2 (0 by default) – detailed description:
http://sqlite.org/pragma.html#pragma_temp_store
PRAGMA page_size = bytes (1024 by default) - detailed description:
http://sqlite.org/pragma.html#pragma_page_size
It is recommended to set the bytes value equal to the disk cluster size

Modification of these parameter values will increase performance when working with the database. However, note, that this improvement is achieved by reducing reliability or functionality loss. So, for example, Synchronous=0 increases the risk of data loss in case of failures, and the OFF value of the Journal_Mode parameter will lead to inability to use transaction rollbacks.

Mike at Bookup
Posts: 11
Joined: Fri 25 Sep 2015 14:02

Re: Slowdown on MacOS

Post by Mike at Bookup » Mon 12 Oct 2015 14:36

MaximG wrote:To increase performance when using SQLite, you can use the following PRAGMA statements:

PRAGMA synchronous = 0 (2 by default) – detailed description:
Thanks.

My production app (Mac and Windows) already uses these optimizations, except for the "temp_store" one.

I'm still confused as to how the same app on the same Mac can run more than twice as fast on that Mac - if it's run as a Windows app inside a VM.

Mike at Bookup
Posts: 11
Joined: Fri 25 Sep 2015 14:02

Re: Slowdown on MacOS

Post by Mike at Bookup » Sat 17 Oct 2015 17:07

I'm still confused about how the same app runs more than twice as fast on Windows inside a VM inside of Mac OS than it runs on the Mac OS itself.

How do I get similar or better performance with a native Mac OS that my app gets inside of Windows running on a Mac?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Slowdown on MacOS

Post by MaximG » Mon 19 Oct 2015 08:35

Unfortunately, we can't affect this case. This behavior is not related to LiteDAC implementation. It is only due to difference in file operations execution speed in MacOS and Windows systems.

Mike at Bookup
Posts: 11
Joined: Fri 25 Sep 2015 14:02

Re: Slowdown on MacOS

Post by Mike at Bookup » Mon 19 Oct 2015 16:43

MaximG wrote:Unfortunately, we can't affect this case. This behavior is not related to LiteDAC implementation. It is only due to difference in file operations execution speed in MacOS and Windows systems.
There are definitely differences in the MacOS and Windows file operations.

However, if I run the same queries using LiteDAC code inside of Windows which is inside a VM which is then using the very same MacOS file operations, how is it getting more than twice the speed?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Slowdown on MacOS

Post by MaximG » Tue 20 Oct 2015 10:34

We have composed a small sample for measuring file operations performance. After the application starts, click sequentially Create and Test buttons, then you will see the execution time in the below window. Please run this sample on the MacOS you are using, then on Windows on a virtual machine - and let us know the results for both systems. Please send your e-mail address to maximg*devart*com, in order for us to send you the sample.

Mike at Bookup
Posts: 11
Joined: Fri 25 Sep 2015 14:02

Re: Slowdown on MacOS

Post by Mike at Bookup » Tue 27 Oct 2015 21:29

I've run the sample program. It shows that file access from the Mac app is six times faster than file access in Windows on a VM on that Mac.

Despite the 6X handicap, LiteDAC executes queries many times faster inside a Windows app (in a VM) on the Mac compared to inside a native Mac app.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Slowdown on MacOS

Post by MaximG » Thu 05 Nov 2015 13:52

Since investigation of performance of Windows and Мас OS X file systems didn't show any outperformance of file operations on Windows running in MacOS virtual environment , then we assume the loss in query execution speed is due to some specificity of SQLite implementation for Мас OS X. In LiteDAC we use SQLite sources available on the official SQLite website, and we can't affect their behavior, unfortunately.

Post Reply