2

I have been using the latest version 10.3 of Delphi to create both 32-bit executables and 64-bit executables for my users for the past few years. I have noticed that the 64-bit version consistently runs 10% to 25% slower than the 32-bit version.

My program is a self-contained VCL-based executable that does not use any external DLLs. My Release configuration compiler options are the same for 32-bit and 64-bit. Both have Optimization = true.

I had thought that was just the way it is. But today, I was comparing a 32-bit version of a C++ program to the same program in 64-bit, and I found that the 64-bit program was 5% to 10% faster than the 32-bit version.

In addition to that, I found this article: Integer Performance Comparison for C++, C#, Delphi which included a table and chart definitely showing Delphi Win64 faster than Delphi Win32: enter image description here

So my questions are:

  1. Are there any Delphi compiler settings that should be changed for 64-bit builds?

  2. Which of the following types of processing are slower in 64-bit Delphi than 32-bit?

    • memory-intensive processing?
    • extensive numeric calculations?
    • lots of string manipulation?
    • large amount of disk reading/writing?
    • heavy database access?
lkessler
  • 19,819
  • 36
  • 132
  • 203
  • 1
    Have you tried using alternatives to Delphi for performance comparisons, such as [Free Pascal](https://www.freepascal.org/) or RemObjects [Oxygene](https://www.elementscompiler.com/elements/oxygene/)? Could be that Delphi doesn't optimize as well as some of the other vendors' compilers. – Eljay May 19 '20 at 03:33
  • @Eljay - No. Delphi is the only language I use. Delphi is known to have an excellent optimizing compiler. – lkessler May 19 '20 at 03:41
  • More bits does not mean faster performance. Most 64-bit applications execute slower than the same code in 32-bit. The only real advantage of 64-bit code is that you have a larger memory address space, meaning you can use more memory. If you don't need that, leave your code 32-bit. – Ken White May 19 '20 at 03:42
  • @KenWhite - What you say was my original thinking. But when I found these two examples to the contrary, I started wondering if that's true, so I asked my question. – lkessler May 19 '20 at 04:10
  • 3
    @KenWhite that's simply not true. Most [x86-64 applications run ~15% faster on average](https://stackoverflow.com/a/4931584/995714) due to the bigger register space and the use of SSE. Same to ARM64. There are countless of benchmarks out there and only when an app uses too much pointers then the 64-bit version will be slower. It's not like classic RISC architectures like MIPS or SPARC where the only advantage is the bigger memory address space – phuclv May 19 '20 at 04:44
  • 1
    Please show a [mre]. Otherwise you'll just have to profile your program and find out where it's slow – Alan Birtles May 19 '20 at 07:16
  • 6
    "Delphi is known to have an excellent optimizing compiler." If only that were true. Sadly it isn't. Delphi's compiler is in fact known for producing rather inefficient code. – David Heffernan May 19 '20 at 07:38
  • 1
    @Ken for floating point heavy applications you can expect up to twice the performance in 64 bit as you get in 32 bit, for Delphi programs. – David Heffernan May 19 '20 at 07:39
  • 2
    @lkessler The answer to your question is basically dependent on what your program does. As such your question is too broad for this site. – David Heffernan May 19 '20 at 07:40
  • @DavidHeffernan - I've made my question less broad by changing the last two paragraphs into two specific questions – lkessler May 19 '20 at 17:19
  • Answer to Q1 is, "no", Q2 is too broad – David Heffernan May 19 '20 at 17:28
  • @DavidHeffernan - I've updated Q2 again to make it less broad. – lkessler May 19 '20 at 17:57
  • Still too broad. One question at a time here. Best to give up. – David Heffernan May 19 '20 at 20:26
  • If your example is floating point heavy, check http://docwiki.embarcadero.com/RADStudio/Sydney/en/Floating_point_precision_control_(Delphi_for_x64) – Marco van de Voort Jun 17 '21 at 20:03

1 Answers1

1

Was this under the IDE? I notice a significant slow down running 64-bit vs 32-bit under the IDE running a simple process that takes about 5-10 seconds. However, this is not true for me when run outside of the IDE. So I tend to debug in 32bit.

Running that same simple process in 64bit outside of the IDE seems maybe slightly faster than the 32bit version.

Edited as a follow-up to clarify what my process was:

My process is loading an XML file into a clientdataset followed by reads/writes to a Firebird local 64-bit server via either my 32 or 64 version compiled in Debug. Also using CData's AWS DynamoDB access is significantly slower compiled in 64bit vs 32 bit under the IDE, however that AWS access in the 64bit app is faster than the 32bit outside of the IDE. Go figure.

  • That's an interesting idea. I tested that out and it doesn't seem to be whether it's in the IDE or not that makes a difference, but it's whether it's built with Debug or Release. One test I use built with Debug takes 3.10 seconds for 32-bit, and 3.57 seconds for 64-bit. The same test in Release takes 3.45 seconds for 32-bit and 3.49 seconds for 64-bit. – lkessler Aug 28 '20 at 02:26
  • Even so, my 64-bit Release time is still not faster than my 32-bit Release time and it should be noticeably faster. Why Debug 32-bit is faster than all the others is also strange to me. (Note: I did several runs and averaged them. Times for one configuration didn't vary more than 0.1 seconds) – lkessler Aug 28 '20 at 02:27