May 2025
We have a significant workload (> 50k CPU hours per year) on AWS EC2 instances running a Windows program. Since Linux instances are cheaper and easier to maintain (think Docker), we tried to get that Windows application running using Wine. A native Linux port is unfortunately not feasible, since the application depends on some closed-source libraries.
Initial benchmarks were not encouraging:
Platform | Runtime |
---|---|
Windows 11 | 479 s |
Linux 6.12 | 2636 s |
Wine offers nice logging/tracing abilities by setting the environment variable WINEDEBUG=+relay,+heap
.
This revealed far too many calls to heap allocation functions. Since the application is statically linked against the C runtime,
Wine's heap allocation function may be less optimized than the original Windows function or require more overhead.
Also perf top
points to Wine's heap_allocation_block
function.
mimalloc is a general purpose memory allocator with excellent performance.
For statically-linked programs, it is possible to override the global C++ new
and delete
operators by just
#including mimalloc-new-delete.h
in one source file.
Benchmarks for the same program/workload as above, statically linked with mimalloc:
Platform | Allocator | Runtime | Peak Memory |
---|---|---|---|
Windows 11 | default | 479 s | 12.6 GB |
Windows 11 | mimalloc v3.0.3 | 438 s | 12.2 GB |
Windows 11 | mimalloc v2.2.3 | 440 s | 12.9 GB |
Linux 6.12 | default | 2636 s | 14.3 GB |
Linux 6.12 | mimalloc v3.0.3 | crash | N/A |
Linux 6.12 | mimalloc v2.2.3 | 435 s | 12.4 GB |
The crash on Linux with mimalloc v3.0.3 is probably related to issue #1087 and due to the new page-map feature having trouble with low addresses of memory allocations (which Wine provides) -- looking forward to a fix!
posted at: 12:46 | path: /programming | permanent link