Memory Manager

Recently a new version of FastMM, developed by Pierre le Riche, has been released, the new version is called FastMM5 and has been rewritten to improve the performance on multi threaded applications, can be configured for better speed or less memory usage and more.

Support from Delphi XE3 Compiler and can used on Windows32 and Windows64.

FastMM5 is dual licensed, so there are 2 licenses: GPL and Commercial. So if you want use in commercial projects, you must purchase a license. More details here

https://github.com/pleriche/FastMM5

FastMM4 has a new fork, called FastMM4-AVX, developed by Maxim Masiutin, which adds very interesting features like: more efficient synchronization, AVX instructions for faster memory copy, speed improvements and more. FastMM4-AVX is dual licensed: MPL and GPL. More details here:

https://github.com/maximmasiutin/FastMM4-AVX

Configuration

In order to test the performance with our components, a new windows console application has been created, sgcBenchmark.exe, which will be used to measure the performance of every memory manager using our sgcWebSockets components.

The test is very simple, a client (or more than one client) connects to a server, sends a message to server and server replies with the same message to client. This is repeated 100.000 times. The tests are repeated changing the number of concurrent clients, first 1, then 10, 100... the measured time is the time elapsed between the first message sent by client and the last message received from server (so the time used to connect to server is not measured).

The benchmark will compare the performance using the Default Memory Manager that comes with Delphi 10.4.1, FastMM5 and FastMM4-AVX

Benchmark Indy WebSocket Server

In the first Benchmark, the Server used is the Indy WebSocket Server, this server is based on Indy TCP Server, so every connection creates 1 thread. 

The values are measured in milliseconds, so for example, the first test that is done with 1 client in Windows32 platforms, using the default memory manager takes 4135 milliseconds, using FastMM5 takes 4214 milliseconds and using FastMM4-AVX takes 4823 milliseconds. The percentage calculated is against the reference value, in this case against the Default memory manager that comes with delphi, as much lower is the percentage, better performance has.

The Benchmark has been done 3 times and the values showed are the sum of the benchmarks / 3.

For the benchmark, the server used was:

The Delphi version used was Delphi 10.4.1, and the latest FastMM5 and FastMM4-AVX versions from github servers.

Find below the result of the benchmark.

Clients Platform Default  (ms) FMM5 (ms) FMM5 (%) FMM4-AVX (ms) FMM4-AVX (%)
1 Win32 4135 4214 1.91% 4823 16.64%
1 Win64 4052 4520 11.55% 4328 6.81%
10 Win32 4214 1729 -58.97% 1828 -56.62%
10 Win64 4104 1875 -54.31% 1651 -59.77%
100 Win32 3958 1604 -59.47% 1583 -60.01%
100 Win64 3958 1614 -59.22% 1635 -58.69%
500 Win32 4098 1723 -57.96% 1854 -54.76%
500 Win64 5333 1791 -66.42% 1833 -65.63%
1000 Win32 5927 2208 -62.75% 2328 -60.72%
1000 Win64 8166 2229 -72.70% 2234 -72.64%

Benchmark HTTP.SYS Server

In the second Benchmark, the Server used is the HTTP.SYS WebSocket Server, this server is based on HTTP API Microsoft Framework and the connections are handled by a pool of threads.

The values are measured in milliseconds, so for example, the first test that is done with 1 client in Windows32 platforms, using the default memory manager takes 5364 milliseconds, using FastMM5 takes 5182 milliseconds and using FastMM4-AVX takes 5838 milliseconds. The percentage calculated is against the reference value, in this case against the Default memory manager that comes with Delphi, as much lower is the percentage, better performance has.

The Benchmark has been done 3 times and the values showed are the sum of the benchmarks / 3.

For the benchmark, the server used was:

The Delphi version used was Delphi 10.4.1, and the latest FastMM5 and FastMM4-AVX versions from github servers.

Find below the result of the benchmark.

Clients Platform Default  (ms) FMM5 (ms) FMM5 (%) FMM4-AVX (ms) FMM4-AVX (%)
1 Win32 5364 5182 -3.39% 5838 8.84%
1 Win64 5507 5206 -0.61% 5135 1.54%
10 Win32 4922 1744 -64.57% 2088 -57.58%
10 Win64 4958 1770 -64.30% 1953 -60.61%
100 Win32 3359 1682 -49.93% 2244 -33.19%
100 Win64 3979 1536 -61.40% 1859 -53.28%
500 Win32 2364 1890 -20.05% 2344 -0.85%
500 Win64 2901 1666 -42.57% 1859 -35.92%
1000 Win32 3296 1968 -40.29% 2531 -23.21%
1000 Win64 4469 1989 -55.49% 2047 -54.20%

Comments about Benchmarks

Find below some comments about the results obtained after benchmark the 3 different memory managers:


 

The final decision to choose one memory manager or another depends of the project, I think there is no single memory manager that works as the best in all conditions, so before choose one or another, test, test and test again to see which performance better for your needs