I would like to run some kind of a benchmark in order to find out the exact difference in performance between the 32-bit and 64-bit versions of Syncthing.
Until now, I have always preferred to use the 32-bit version simply to reduce the RAM usage, but I have no actual hard data to prove that there is any significant difference in this regard. I would also like to know how much of a performance gain there is regarding CPU operations like hashing, etc.
Could anyone recommend a simple method to do this kind of benchmarks? I know that Syncthing logs the hashing performance on each start, so I can use that for some basic comparison, and also check compare the RAM usage of each version using the OS tools. Is there anything else that I could compare?
Hashing depends on CPU. 32-bit vs. 64-bit is usually seen in RAM usage (limits). Some time ago I was running 32-bit version and often had crashes because of high RAM usage with millions of files in Syncthing.
It is generally possible to use 32-bit pointers to decreases the memory footprint of a program and also increase the speed of the execution, e.g. x32 ABI - Wikipedia. Syncthing might benefit from that. Not sure whether golang and the platform you have in mind support an ABI like that.
The reduced memory footprint might also count for the plain i386 build of Syncthing but likely the performance is impaired because it can not make use of x86_64 instructions.
But most of our types in syncthing are 64bit sized, so most instructions end up being two instructions on a 32bit platform. So my gut says it will he slower by some small amount.
Hashing is assembly anyway, so I doubt it would matter, as I suspect it does cpu feature detection.
Other than perhaps old cpus more likely being 32bit amd not having SSE/AVX and it all being software implemented (hence slow), but this is irrelevant to the 32vs64 comparison. I also suspect you could hit bugs/edge cases with 32 bit platforms that we had before with int overflows etc which we haven’t accounted for. There were a few of those in the past.
In the meantime, I have compared the actual hashing performance reported by Syncthing on start. I used the official binaries of Syncthing v1.13.1 for Windows, and all the testing was performed in Windows 10. The CPU is AMD Ryzen 4350G.
Contrary to the predictions, there seems to be a massive difference in the hashing performance between the two. I used the same fresh config with no folders, and run both versions three times each. The results were always reproducible, so this is not a fluke.
Syncthing v1.13.1 x86-32
INFO: Single thread SHA256 performance is 268 MB/s using crypto/sha256 (264 MB/s using minio/sha256-simd).
INFO: Hashing performance is 235.24 MB/s
Syncthing v1.13.1 x86-64
INFO: Single thread SHA256 performance is 1909 MB/s using minio/sha256-simd (470 MB/s using crypto/sha256).
INFO: Hashing performance is 1085.84 MB/s
I am going to repeat this in a different system later on just to double check, but if these numbers are true, then there is no question which one should be used (unless the CPU/OS is 32-bit only).
I could not stop myself from running just one more test using a very weak AMD A6-4400M laptop CPU this time. The difference here is less drastic, but still clearly noticeable.
x86-32
INFO: Single thread SHA256 performance is 44 MB/s using crypto/sha256 (43 MB/s using minio/sha256-simd).
INFO: Hashing performance is 38.21 MB/s
x86-64
INFO: Single thread SHA256 performance is 70 MB/s using minio/sha256-simd (59 MB/s using crypto/sha256).
INFO: Hashing performance is 64.51 MB/s