UseSWIG: Huge performance drop in C# bindings when SWIG library type is `MODULE` compared to `SHARED`
This is a slightly early issue report, because I still lack more details as to what may be causing the problem. Here is what I observe:
I build a C++ native library for C# integration with SWIG, using swig_add_library()
. Then I run a benchmark in C#. The benchmark is quite simple, it calls a native method an transfers 10MB in every call. This is done with an argument of type const unsigned char*
that maps in C# to byte[]
.
When I set the TYPE
to MODULE
, which seems to be the recommended value for what I'm doing, then the performance on Ubuntu Linux is roughly 2GB/sec
. When I set the TYPE
to SHARED
, then the performance on Ubuntu Linux is roughly 4GB/sec
.
I checked a bit the build settings in build.ninja
and could not find big differences. Therefore I have basically no clue what may be going on.
I have repeated this test 5 or 6 times now, building a few times as MODULE
or as SHARED
, and the results are always the same, so it's at least unlikely to be a random effect.