Open arcanis opened 7 years ago
Looks like it might have to do with converting vectors or passing them by value instead of by reference in the nbind version. I'll check this further...
Actually, there is a change that might be a valid cause for the huge difference in perfs:
https://github.com/atom/buffer-offset-index/pull/2/files#diff-a2d4f7ee8b35a4f4edffbf257fe50ccdL56
As you can see, I had to remove a ref-qualifier, which probably means that some extra copies are required. Unfortunately, using a reference on this function triggers a segfault on the native version, and yield a wrong result on the asmjs version.
It seems the benchmarks aren't easily comparable because the representation of points is different. Now that the bug you reported earlier is fixed, try commenting out these lines:
Still not comparable, but again different. You can also comment out the assert.deepEqual
in both your PR and the original master
, and then compare again.
I can't run reasonable benchmarks at the moment because this laptop is randomly changing clock speeds to keep temperatures down.
The following PR lists the changes I had to make to a package to switch it to nbind (from nan). As you can see in the C source codes, I haven't made any critical change, merely changing a few function names and adding a const qualifier. However, when I tried to benchmark it, I noticed that perfs weren't as good as expected:
As you can see, something weird is going on with the native version, which is much, much slower than even the asmjs version. I have no idea what might cause this: I checked the flags that were used when compiling it, and the
-O3
flag was there without a doubt.Have you noticed this odd disparity before?
If you want to try by yourself, you can clone
git@github.com:arcanis/buffer-offset-index
and runnpm run install && npm run bench
(assumingemcc
is in your PATH).