koffi 1.3.5 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CMakeLists.txt +1 -1
  2. package/ChangeLog.md +36 -0
  3. package/benchmark/atoi_koffi.js +3 -4
  4. package/benchmark/atoi_napi.js +2 -3
  5. package/benchmark/atoi_node_ffi.js +3 -4
  6. package/benchmark/raylib_cc.cc +3 -4
  7. package/benchmark/raylib_cc.js +31 -0
  8. package/benchmark/raylib_koffi.js +8 -9
  9. package/benchmark/raylib_node_ffi.js +4 -5
  10. package/benchmark/raylib_node_raylib.js +4 -5
  11. package/build/qemu/1.3.8/koffi_darwin_arm64.tar.gz +0 -0
  12. package/build/qemu/1.3.8/koffi_darwin_x64.tar.gz +0 -0
  13. package/build/qemu/1.3.8/koffi_freebsd_arm64.tar.gz +0 -0
  14. package/build/qemu/1.3.8/koffi_freebsd_ia32.tar.gz +0 -0
  15. package/build/qemu/1.3.8/koffi_freebsd_x64.tar.gz +0 -0
  16. package/build/qemu/1.3.8/koffi_linux_arm32hf.tar.gz +0 -0
  17. package/build/qemu/1.3.8/koffi_linux_arm64.tar.gz +0 -0
  18. package/build/qemu/1.3.8/koffi_linux_ia32.tar.gz +0 -0
  19. package/build/qemu/1.3.8/koffi_linux_riscv64hf64.tar.gz +0 -0
  20. package/build/qemu/1.3.8/koffi_linux_x64.tar.gz +0 -0
  21. package/build/qemu/1.3.8/koffi_openbsd_ia32.tar.gz +0 -0
  22. package/build/qemu/1.3.8/koffi_openbsd_x64.tar.gz +0 -0
  23. package/build/qemu/1.3.8/koffi_win32_arm64.tar.gz +0 -0
  24. package/build/qemu/1.3.8/koffi_win32_ia32.tar.gz +0 -0
  25. package/build/qemu/1.3.8/koffi_win32_x64.tar.gz +0 -0
  26. package/doc/_static/perf_linux_20220627.png +0 -0
  27. package/doc/_static/perf_linux_20220628.png +0 -0
  28. package/doc/_static/perf_windows_20220627.png +0 -0
  29. package/doc/_static/perf_windows_20220628.png +0 -0
  30. package/doc/benchmarks.md +78 -58
  31. package/doc/benchmarks.xlsx +0 -0
  32. package/doc/conf.py +1 -1
  33. package/doc/contribute.md +8 -11
  34. package/doc/dist/html/_sources/benchmarks.md.txt +78 -58
  35. package/doc/dist/html/_sources/contribute.md.txt +8 -11
  36. package/doc/dist/html/_sources/functions.md.txt +9 -8
  37. package/doc/dist/html/_sources/index.rst.txt +3 -0
  38. package/doc/dist/html/_sources/platforms.md.txt +17 -5
  39. package/doc/dist/html/_sources/start.md.txt +14 -3
  40. package/doc/dist/html/_sources/types.md.txt +15 -11
  41. package/doc/dist/html/_static/basic.css +12 -14
  42. package/doc/dist/html/_static/perf_linux_20220627.png +0 -0
  43. package/doc/dist/html/_static/perf_linux_20220628.png +0 -0
  44. package/doc/dist/html/_static/perf_windows_20220627.png +0 -0
  45. package/doc/dist/html/_static/perf_windows_20220628.png +0 -0
  46. package/doc/dist/html/benchmarks.html +148 -159
  47. package/doc/dist/html/changes.html +44 -2
  48. package/doc/dist/html/contribute.html +30 -33
  49. package/doc/dist/html/functions.html +19 -18
  50. package/doc/dist/html/genindex.html +2 -2
  51. package/doc/dist/html/index.html +19 -10
  52. package/doc/dist/html/memory.html +2 -2
  53. package/doc/dist/html/objects.inv +0 -0
  54. package/doc/dist/html/platforms.html +44 -10
  55. package/doc/dist/html/search.html +2 -2
  56. package/doc/dist/html/searchindex.js +1 -1
  57. package/doc/dist/html/start.html +25 -12
  58. package/doc/dist/html/types.html +31 -11
  59. package/doc/functions.md +9 -8
  60. package/doc/index.rst +3 -0
  61. package/doc/platforms.md +17 -5
  62. package/doc/start.md +14 -3
  63. package/doc/types.md +15 -11
  64. package/package.json +7 -4
  65. package/qemu/qemu.js +30 -19
  66. package/qemu/registry/machines.json +19 -19
  67. package/qemu/registry/sha256sum.txt +5 -5
  68. package/src/abi_arm32.cc +9 -2
  69. package/src/abi_arm32_fwd.S +7 -7
  70. package/src/abi_arm64.cc +9 -2
  71. package/src/abi_arm64_fwd.S +11 -7
  72. package/src/abi_arm64_fwd.asm +7 -7
  73. package/src/abi_riscv64.cc +9 -2
  74. package/src/abi_riscv64_fwd.S +11 -11
  75. package/src/abi_x64_sysv.cc +9 -2
  76. package/src/abi_x64_sysv_fwd.S +11 -11
  77. package/src/abi_x64_win.cc +9 -2
  78. package/src/abi_x64_win_fwd.asm +7 -7
  79. package/src/abi_x86.cc +9 -2
  80. package/src/abi_x86_fwd.S +3 -0
  81. package/src/abi_x86_fwd.asm +3 -0
  82. package/src/call.cc +20 -10
  83. package/src/ffi.cc +17 -8
  84. package/src/ffi.hh +4 -3
  85. package/src/util.cc +1 -1
  86. package/test/async.js +1 -1
  87. package/test/callbacks.js +25 -2
  88. package/test/misc.c +57 -2
  89. package/test/raylib.js +4 -4
  90. package/test/sqlite.js +5 -5
  91. package/test/sync.js +22 -7
  92. package/build/qemu/1.3.5/koffi_darwin_arm64.tar.gz +0 -0
  93. package/build/qemu/1.3.5/koffi_darwin_x64.tar.gz +0 -0
  94. package/build/qemu/1.3.5/koffi_freebsd_arm64.tar.gz +0 -0
  95. package/build/qemu/1.3.5/koffi_freebsd_ia32.tar.gz +0 -0
  96. package/build/qemu/1.3.5/koffi_freebsd_x64.tar.gz +0 -0
  97. package/build/qemu/1.3.5/koffi_linux_arm32hf.tar.gz +0 -0
  98. package/build/qemu/1.3.5/koffi_linux_arm64.tar.gz +0 -0
  99. package/build/qemu/1.3.5/koffi_linux_ia32.tar.gz +0 -0
  100. package/build/qemu/1.3.5/koffi_linux_riscv64hf64.tar.gz +0 -0
  101. package/build/qemu/1.3.5/koffi_linux_x64.tar.gz +0 -0
  102. package/build/qemu/1.3.5/koffi_openbsd_ia32.tar.gz +0 -0
  103. package/build/qemu/1.3.5/koffi_openbsd_x64.tar.gz +0 -0
  104. package/build/qemu/1.3.5/koffi_win32_arm64.tar.gz +0 -0
  105. package/build/qemu/1.3.5/koffi_win32_ia32.tar.gz +0 -0
  106. package/build/qemu/1.3.5/koffi_win32_x64.tar.gz +0 -0
@@ -5,7 +5,7 @@
5
5
  <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
6
6
  <link rel="index" title="Index" href="genindex" /><link rel="search" title="Search" href="search" /><link rel="next" title="Contributing" href="contribute" /><link rel="prev" title="Memory usage" href="memory" />
7
7
 
8
- <meta name="generator" content="sphinx-5.0.1, furo 2022.06.04.1"/>
8
+ <meta name="generator" content="sphinx-5.0.2, furo 2022.06.21"/>
9
9
  <title>Benchmarks - Koffi</title>
10
10
  <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
11
11
  <link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=40978830699223671f4072448e654b5958f38b89" />
@@ -162,7 +162,7 @@
162
162
  </form>
163
163
  <div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
164
164
  <ul class="current">
165
- <li class="toctree-l1"><a class="reference internal" href="platforms">Supported platforms</a></li>
165
+ <li class="toctree-l1"><a class="reference internal" href="platforms">Requirements</a></li>
166
166
  <li class="toctree-l1"><a class="reference internal" href="start">Quick start</a></li>
167
167
  <li class="toctree-l1"><a class="reference internal" href="types">Data types</a></li>
168
168
  <li class="toctree-l1"><a class="reference internal" href="functions">Function calls</a></li>
@@ -205,6 +205,8 @@
205
205
  <article role="main">
206
206
  <section id="benchmarks">
207
207
  <h1>Benchmarks<a class="headerlink" href="#benchmarks" title="Permalink to this heading">#</a></h1>
208
+ <section id="overview">
209
+ <h2>Overview<a class="headerlink" href="#overview" title="Permalink to this heading">#</a></h2>
208
210
  <p>Here is a quick overview of the execution time of Koffi calls on three benchmarks, where it is compared to a theoretical ideal FFI implementation (approximated with pre-compiled static N-API glue code):</p>
209
211
  <ul class="simple">
210
212
  <li><p>The first benchmark is based on <code class="docutils literal notranslate"><span class="pre">rand()</span></code> calls</p></li>
@@ -213,272 +215,261 @@
213
215
  </ul>
214
216
  <table style="margin: 0 auto;">
215
217
  <tr>
216
- <td><a href="_static/perf_linux_20220623_2.png" target="_blank"><img src="_static/perf_linux_20220623_2.png" alt="Linux performance" style="width: 350px;"/></a></td>
217
- <td><a href="_static/perf_windows_20220623_2.png" target="_blank"><img src="_static/perf_windows_20220623_2.png" alt="Windows performance" style="width: 350px;"/></a></td>
218
+ <td><a href="_static/perf_linux_20220628.png" target="_blank"><img src="_static/perf_linux_20220628.png" alt="Linux performance" style="width: 350px;"/></a></td>
219
+ <td><a href="_static/perf_windows_20220628.png" target="_blank"><img src="_static/perf_windows_20220628.png" alt="Windows performance" style="width: 350px;"/></a></td>
218
220
  </tr>
219
221
  </table>
220
222
  <p>These results are detailed and explained below, and compared to node-ffi/node-ffi-napi.</p>
223
+ </section>
224
+ <section id="linux-x86-64">
225
+ <h2>Linux x86_64<a class="headerlink" href="#linux-x86-64" title="Permalink to this heading">#</a></h2>
226
+ <p>The results presented below were measured on my x86_64 Linux machine (Intel® Core™ i5-4460).</p>
221
227
  <section id="rand-results">
222
- <h2>rand results<a class="headerlink" href="#rand-results" title="Permalink to this heading">#</a></h2>
228
+ <h3>rand results<a class="headerlink" href="#rand-results" title="Permalink to this heading">#</a></h3>
223
229
  <p>This test is based around repeated calls to a simple standard C function atoi, and has three implementations:</p>
224
230
  <ul class="simple">
225
231
  <li><p>the first one is the reference, it calls atoi through an N-API module, and is close to the theoretical limit of a perfect (no overhead) Node.js &gt; C FFI implementation (pre-compiled static glue code)</p></li>
226
232
  <li><p>the second one calls atoi through Koffi</p></li>
227
233
  <li><p>the third one uses the official Node.js FFI implementation, node-ffi-napi</p></li>
228
234
  </ul>
229
- <p>Because rand is a pretty small function, the FFI overhead is clearly visible.</p>
230
- <section id="linux-x86-64">
231
- <h3>Linux x86_64<a class="headerlink" href="#linux-x86-64" title="Permalink to this heading">#</a></h3>
232
- <p>The results below were measured on my x86_64 Linux machine (AMD® Ryzen™ 7 4700U):</p>
233
235
  <div class="table-wrapper colwidths-auto docutils container">
234
236
  <table class="docutils align-default">
235
237
  <thead>
236
238
  <tr class="row-odd"><th class="head"><p>Benchmark</p></th>
237
- <th class="head"><p>Iterations</p></th>
238
- <th class="head"><p>Total time</p></th>
239
+ <th class="head"><p>Iteration time</p></th>
239
240
  <th class="head"><p>Relative performance</p></th>
240
241
  <th class="head"><p>Overhead</p></th>
241
242
  </tr>
242
243
  </thead>
243
244
  <tbody>
244
245
  <tr class="row-even"><td><p>rand_napi</p></td>
245
- <td><p>20000000</p></td>
246
- <td><p>1.44s</p></td>
247
- <td><p>(baseline)</p></td>
248
- <td><p>(baseline)</p></td>
246
+ <td><p>644 ns</p></td>
247
+ <td><p>x1.00</p></td>
248
+ <td><p>(ref)</p></td>
249
249
  </tr>
250
250
  <tr class="row-odd"><td><p>rand_koffi</p></td>
251
- <td><p>20000000</p></td>
252
- <td><p>2.60s</p></td>
253
- <td><p>x0.55</p></td>
254
- <td><p>+81%</p></td>
251
+ <td><p>950 ns</p></td>
252
+ <td><p>x0.68</p></td>
253
+ <td><p>+48%</p></td>
255
254
  </tr>
256
255
  <tr class="row-even"><td><p>rand_node_ffi</p></td>
257
- <td><p>20000000</p></td>
258
- <td><p>107.58s</p></td>
259
- <td><p>x0.01</p></td>
260
- <td><p>+7400%</p></td>
256
+ <td><p>30350 ns</p></td>
257
+ <td><p>x0.02</p></td>
258
+ <td><p>+4613%</p></td>
261
259
  </tr>
262
260
  </tbody>
263
261
  </table>
264
262
  </div>
263
+ <p>Because rand is a pretty small function, the FFI overhead is clearly visible.</p>
265
264
  </section>
266
- <section id="windows-x86-64">
267
- <h3>Windows x86_64<a class="headerlink" href="#windows-x86-64" title="Permalink to this heading">#</a></h3>
268
- <p>The results below were measured on my x86_64 Windows machine (Intel® Core™ i5-4460):</p>
265
+ <section id="atoi-results">
266
+ <h3>atoi results<a class="headerlink" href="#atoi-results" title="Permalink to this heading">#</a></h3>
267
+ <p>This test is similar to the rand one, but it is based on atoi, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.</p>
269
268
  <div class="table-wrapper colwidths-auto docutils container">
270
269
  <table class="docutils align-default">
271
270
  <thead>
272
271
  <tr class="row-odd"><th class="head"><p>Benchmark</p></th>
273
- <th class="head"><p>Iterations</p></th>
274
- <th class="head"><p>Total time</p></th>
272
+ <th class="head"><p>Iteration time</p></th>
275
273
  <th class="head"><p>Relative performance</p></th>
276
274
  <th class="head"><p>Overhead</p></th>
277
275
  </tr>
278
276
  </thead>
279
277
  <tbody>
280
- <tr class="row-even"><td><p>rand_napi</p></td>
281
- <td><p>20000000</p></td>
282
- <td><p>2.10s</p></td>
283
- <td><p>(baseline)</p></td>
284
- <td><p>(baseline)</p></td>
278
+ <tr class="row-even"><td><p>atoi_napi</p></td>
279
+ <td><p>1104 ns</p></td>
280
+ <td><p>x1.00</p></td>
281
+ <td><p>(ref)</p></td>
285
282
  </tr>
286
- <tr class="row-odd"><td><p>rand_koffi</p></td>
287
- <td><p>20000000</p></td>
288
- <td><p>3.87s</p></td>
289
- <td><p>x0.54</p></td>
290
- <td><p>+84%</p></td>
283
+ <tr class="row-odd"><td><p>atoi_koffi</p></td>
284
+ <td><p>1778 ns</p></td>
285
+ <td><p>x0.62</p></td>
286
+ <td><p>+61%</p></td>
291
287
  </tr>
292
- <tr class="row-even"><td><p>rand_node_ffi</p></td>
293
- <td><p>20000000</p></td>
294
- <td><p>87.84s</p></td>
295
- <td><p>x0.02</p></td>
296
- <td><p>+4100%</p></td>
288
+ <tr class="row-even"><td><p>atoi_node_ffi</p></td>
289
+ <td><p>125300 ns</p></td>
290
+ <td><p>x0.009</p></td>
291
+ <td><p>+11250%</p></td>
297
292
  </tr>
298
293
  </tbody>
299
294
  </table>
300
295
  </div>
296
+ <p>Because atoi is a pretty small function, the FFI overhead is clearly visible.</p>
301
297
  </section>
302
- </section>
303
- <section id="atoi-results">
304
- <h2>atoi results<a class="headerlink" href="#atoi-results" title="Permalink to this heading">#</a></h2>
305
- <p>This test is similar to the rand one, but it is based on atoi, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.</p>
306
- <p>Because rand is a pretty small function, the FFI overhead is clearly visible.</p>
307
- <section id="id1">
308
- <h3>Linux x86_64<a class="headerlink" href="#id1" title="Permalink to this heading">#</a></h3>
309
- <p>The results below were measured on my x86_64 Linux machine (AMD® Ryzen™ 7 4700U):</p>
298
+ <section id="raylib-results">
299
+ <h3>Raylib results<a class="headerlink" href="#raylib-results" title="Permalink to this heading">#</a></h3>
300
+ <p>This benchmark uses the CPU-based image drawing functions in Raylib. The calls are much heavier than in the atoi benchmark, thus the FFI overhead is reduced. In this implementation, Koffi is compared to:</p>
301
+ <ul class="simple">
302
+ <li><p>Baseline: Full C++ version of the code (no JS)</p></li>
303
+ <li><p><a class="reference external" href="https://github.com/RobLoach/node-raylib">node-raylib</a>: This is a native wrapper implemented with N-API</p></li>
304
+ </ul>
310
305
  <div class="table-wrapper colwidths-auto docutils container">
311
306
  <table class="docutils align-default">
312
307
  <thead>
313
308
  <tr class="row-odd"><th class="head"><p>Benchmark</p></th>
314
- <th class="head"><p>Iterations</p></th>
315
- <th class="head"><p>Total time</p></th>
309
+ <th class="head"><p>Iteration time</p></th>
316
310
  <th class="head"><p>Relative performance</p></th>
317
311
  <th class="head"><p>Overhead</p></th>
318
312
  </tr>
319
313
  </thead>
320
314
  <tbody>
321
- <tr class="row-even"><td><p>atoi_napi</p></td>
322
- <td><p>20000000</p></td>
323
- <td><p>2.97s</p></td>
324
- <td><p>(baseline)</p></td>
325
- <td><p>(baseline)</p></td>
315
+ <tr class="row-even"><td><p>raylib_cc</p></td>
316
+ <td><p>215.7 µs</p></td>
317
+ <td><p>x1.20</p></td>
318
+ <td><p>-17%</p></td>
326
319
  </tr>
327
- <tr class="row-odd"><td><p>atoi_koffi</p></td>
328
- <td><p>20000000</p></td>
329
- <td><p>5.07s</p></td>
330
- <td><p>x0.58</p></td>
331
- <td><p>+71%</p></td>
320
+ <tr class="row-odd"><td><p>raylib_node_raylib</p></td>
321
+ <td><p>258.9 µs</p></td>
322
+ <td><p>x1.00</p></td>
323
+ <td><p>(ref)</p></td>
332
324
  </tr>
333
- <tr class="row-even"><td><p>atoi_node_ffi</p></td>
334
- <td><p>20000000</p></td>
335
- <td><p>693.16s</p></td>
336
- <td><p>x0.005</p></td>
337
- <td><p>+23000%</p></td>
325
+ <tr class="row-even"><td><p>raylib_koffi</p></td>
326
+ <td><p>311.6 µs</p></td>
327
+ <td><p>x0.83</p></td>
328
+ <td><p>+20%</p></td>
329
+ </tr>
330
+ <tr class="row-odd"><td><p>raylib_node_ffi</p></td>
331
+ <td><p>928.4 µs</p></td>
332
+ <td><p>x0.28</p></td>
333
+ <td><p>+259%</p></td>
338
334
  </tr>
339
335
  </tbody>
340
336
  </table>
341
337
  </div>
342
338
  </section>
343
- <section id="id2">
344
- <h3>Windows x86_64<a class="headerlink" href="#id2" title="Permalink to this heading">#</a></h3>
345
- <p>The results below were measured on my x86_64 Windows machine (Intel® Core™ i5-4460):</p>
339
+ </section>
340
+ <section id="windows-x86-64">
341
+ <h2>Windows x86_64<a class="headerlink" href="#windows-x86-64" title="Permalink to this heading">#</a></h2>
342
+ <p>The results presented below were measured on my x86_64 Windows machine (Intel® Core™ i5-4460).</p>
343
+ <section id="id1">
344
+ <h3>rand results<a class="headerlink" href="#id1" title="Permalink to this heading">#</a></h3>
345
+ <p>This test is based around repeated calls to a simple standard C function atoi, and has three implementations:</p>
346
+ <ul class="simple">
347
+ <li><p>the first one is the reference, it calls atoi through an N-API module, and is close to the theoretical limit of a perfect (no overhead) Node.js &gt; C FFI implementation (pre-compiled static glue code)</p></li>
348
+ <li><p>the second one calls atoi through Koffi</p></li>
349
+ <li><p>the third one uses the official Node.js FFI implementation, node-ffi-napi</p></li>
350
+ </ul>
346
351
  <div class="table-wrapper colwidths-auto docutils container">
347
352
  <table class="docutils align-default">
348
353
  <thead>
349
354
  <tr class="row-odd"><th class="head"><p>Benchmark</p></th>
350
- <th class="head"><p>Iterations</p></th>
351
- <th class="head"><p>Total time</p></th>
355
+ <th class="head"><p>Iteration time</p></th>
352
356
  <th class="head"><p>Relative performance</p></th>
353
357
  <th class="head"><p>Overhead</p></th>
354
358
  </tr>
355
359
  </thead>
356
360
  <tbody>
357
- <tr class="row-even"><td><p>atoi_napi</p></td>
358
- <td><p>20000000</p></td>
359
- <td><p>2.97s</p></td>
360
- <td><p>(baseline)</p></td>
361
- <td><p>(baseline)</p></td>
361
+ <tr class="row-even"><td><p>rand_napi</p></td>
362
+ <td><p>965 ns</p></td>
363
+ <td><p>x1.00</p></td>
364
+ <td><p>(ref)</p></td>
362
365
  </tr>
363
- <tr class="row-odd"><td><p>atoi_koffi</p></td>
364
- <td><p>20000000</p></td>
365
- <td><p>5.91s</p></td>
366
- <td><p>x0.50</p></td>
367
- <td><p>+99%</p></td>
366
+ <tr class="row-odd"><td><p>rand_koffi</p></td>
367
+ <td><p>1248 ns</p></td>
368
+ <td><p>x0.77</p></td>
369
+ <td><p>+29%</p></td>
368
370
  </tr>
369
- <tr class="row-even"><td><p>atoi_node_ffi</p></td>
370
- <td><p>20000000</p></td>
371
- <td><p>479.34s</p></td>
372
- <td><p>x0.006</p></td>
373
- <td><p>+16000%</p></td>
371
+ <tr class="row-even"><td><p>rand_node_ffi</p></td>
372
+ <td><p>41500 ns</p></td>
373
+ <td><p>x0.02</p></td>
374
+ <td><p>+4203%</p></td>
374
375
  </tr>
375
376
  </tbody>
376
377
  </table>
377
378
  </div>
379
+ <p>Because rand is a pretty small function, the FFI overhead is clearly visible.</p>
378
380
  </section>
379
- </section>
380
- <section id="raylib-results">
381
- <h2>Raylib results<a class="headerlink" href="#raylib-results" title="Permalink to this heading">#</a></h2>
382
- <p>This benchmark uses the CPU-based image drawing functions in Raylib. The calls are much heavier than in the atoi benchmark, thus the FFI overhead is reduced. In this implementation, Koffi is compared to:</p>
383
- <ul class="simple">
384
- <li><p>Baseline: Full C++ version of the code (no JS)</p></li>
385
- <li><p><a class="reference external" href="https://github.com/RobLoach/node-raylib">node-raylib</a>: This is a native wrapper implemented with N-API</p></li>
386
- </ul>
387
- <section id="id3">
388
- <h3>Linux x86_64<a class="headerlink" href="#id3" title="Permalink to this heading">#</a></h3>
389
- <p>The results below were measured on my x86_64 Linux machine (AMD® Ryzen™ 7 4700U):</p>
381
+ <section id="id2">
382
+ <h3>atoi results<a class="headerlink" href="#id2" title="Permalink to this heading">#</a></h3>
383
+ <p>This test is similar to the rand one, but it is based on atoi, which takes a string parameter. Javascript (V8) to C string conversion is relatively slow and heavy.</p>
384
+ <p>The results below were measured on my x86_64 Windows machine (Intel® Core™ i5-4460):</p>
390
385
  <div class="table-wrapper colwidths-auto docutils container">
391
386
  <table class="docutils align-default">
392
387
  <thead>
393
388
  <tr class="row-odd"><th class="head"><p>Benchmark</p></th>
394
- <th class="head"><p>Iterations</p></th>
395
- <th class="head"><p>Total time</p></th>
389
+ <th class="head"><p>Iteration time</p></th>
396
390
  <th class="head"><p>Relative performance</p></th>
397
391
  <th class="head"><p>Overhead</p></th>
398
392
  </tr>
399
393
  </thead>
400
394
  <tbody>
401
- <tr class="row-even"><td><p>raylib_cc</p></td>
402
- <td><p>100</p></td>
403
- <td><p>9.31s</p></td>
404
- <td><p>x1.17</p></td>
405
- <td><p>-15%</p></td>
406
- </tr>
407
- <tr class="row-odd"><td><p>raylib_node_raylib</p></td>
408
- <td><p>100</p></td>
409
- <td><p>10.90s</p></td>
410
- <td><p>(baseline)</p></td>
411
- <td><p>(baseline)</p></td>
395
+ <tr class="row-even"><td><p>atoi_napi</p></td>
396
+ <td><p>1393 ns</p></td>
397
+ <td><p>x1.00</p></td>
398
+ <td><p>(ref)</p></td>
412
399
  </tr>
413
- <tr class="row-even"><td><p>raylib_koffi</p></td>
414
- <td><p>100</p></td>
415
- <td><p>12.86s</p></td>
416
- <td><p>x0.84</p></td>
417
- <td><p>+18%</p></td>
400
+ <tr class="row-odd"><td><p>atoi_koffi</p></td>
401
+ <td><p>2246 ns</p></td>
402
+ <td><p>x0.62</p></td>
403
+ <td><p>+61%</p></td>
418
404
  </tr>
419
- <tr class="row-odd"><td><p>raylib_node_ffi</p></td>
420
- <td><p>100</p></td>
421
- <td><p>35.76s</p></td>
422
- <td><p>x0.30</p></td>
423
- <td><p>+228%</p></td>
405
+ <tr class="row-even"><td><p>atoi_node_ffi</p></td>
406
+ <td><p>157550 ns</p></td>
407
+ <td><p>x0.009</p></td>
408
+ <td><p>+11210%</p></td>
424
409
  </tr>
425
410
  </tbody>
426
411
  </table>
427
412
  </div>
413
+ <p>Because atoi is a pretty small function, the FFI overhead is clearly visible.</p>
428
414
  </section>
429
- <section id="id4">
430
- <h3>Windows x86_64<a class="headerlink" href="#id4" title="Permalink to this heading">#</a></h3>
431
- <p>The results below were measured on my x86_64 Windows machine (Intel® Core™ i5-4460):</p>
415
+ <section id="id3">
416
+ <h3>Raylib results<a class="headerlink" href="#id3" title="Permalink to this heading">#</a></h3>
417
+ <p>This benchmark uses the CPU-based image drawing functions in Raylib. The calls are much heavier than in the atoi benchmark, thus the FFI overhead is reduced. In this implementation, Koffi is compared to:</p>
418
+ <ul class="simple">
419
+ <li><p><a class="reference external" href="https://github.com/RobLoach/node-raylib">node-raylib</a> (baseline): This is a native wrapper implemented with N-API</p></li>
420
+ <li><p>raylib_cc: C++ implementation of the benchmark, without any Javascript</p></li>
421
+ </ul>
432
422
  <div class="table-wrapper colwidths-auto docutils container">
433
423
  <table class="docutils align-default">
434
424
  <thead>
435
425
  <tr class="row-odd"><th class="head"><p>Benchmark</p></th>
436
- <th class="head"><p>Iterations</p></th>
437
- <th class="head"><p>Total time</p></th>
426
+ <th class="head"><p>Iteration time</p></th>
438
427
  <th class="head"><p>Relative performance</p></th>
439
428
  <th class="head"><p>Overhead</p></th>
440
429
  </tr>
441
430
  </thead>
442
431
  <tbody>
443
432
  <tr class="row-even"><td><p>raylib_cc</p></td>
444
- <td><p>100</p></td>
445
- <td><p>10.67s</p></td>
446
- <td><p>x1.17</p></td>
447
- <td><p>-12%</p></td>
433
+ <td><p>211.8 µs</p></td>
434
+ <td><p>x1.25</p></td>
435
+ <td><p>-20%</p></td>
448
436
  </tr>
449
437
  <tr class="row-odd"><td><p>raylib_node_raylib</p></td>
450
- <td><p>100</p></td>
451
- <td><p>12.05s</p></td>
452
- <td><p>(baseline)</p></td>
453
- <td><p>(baseline)</p></td>
438
+ <td><p>264.4 µs</p></td>
439
+ <td><p>x1.00</p></td>
440
+ <td><p>(ref)</p></td>
454
441
  </tr>
455
442
  <tr class="row-even"><td><p>raylib_koffi</p></td>
456
- <td><p>100</p></td>
457
- <td><p>14.84s</p></td>
458
- <td><p>x0.81</p></td>
459
- <td><p>+23%</p></td>
443
+ <td><p>318.9 µs</p></td>
444
+ <td><p>x0.83</p></td>
445
+ <td><p>+21%</p></td>
460
446
  </tr>
461
447
  <tr class="row-odd"><td><p>raylib_node_ffi</p></td>
462
- <td><p>100</p></td>
463
- <td><p>44.63s</p></td>
464
- <td><p>x0.27</p></td>
465
- <td><p>+270%</p></td>
448
+ <td><p>1146.2 µs</p></td>
449
+ <td><p>x0.23</p></td>
450
+ <td><p>+334%</p></td>
466
451
  </tr>
467
452
  </tbody>
468
453
  </table>
469
454
  </div>
455
+ <p>Please note that in order to get fair numbers for raylib_node_raylib, it was recompiled with clang-cl before running the benchmark with the following commands:</p>
456
+ <div class="highlight-batch notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="k">cd</span> node_modules\raylib
457
+ <span class="linenos">2</span><span class="k">rmdir</span> /S /Q bin build
458
+ <span class="linenos">3</span>npx cmake-js compile -t ClangCL
459
+ </pre></div>
460
+ </div>
470
461
  </section>
471
462
  </section>
472
463
  <section id="running-benchmarks">
473
464
  <h2>Running benchmarks<a class="headerlink" href="#running-benchmarks" title="Permalink to this heading">#</a></h2>
474
465
  <p>Open a console, go to <code class="docutils literal notranslate"><span class="pre">koffi/benchmark</span></code> and run <code class="docutils literal notranslate"><span class="pre">../../cnoke/cnoke.js</span></code> (or <code class="docutils literal notranslate"><span class="pre">node</span> <span class="pre">..\..\cnoke\cnoke.js</span></code> on Windows) before doing anything else.</p>
475
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="nb">cd</span> koffi/benchmark
476
- node ../../cnoke/cnoke.js
466
+ <p>Please note that all benchmark results are made with Clang-built binaries.</p>
467
+ <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span><span class="nb">cd</span> koffi/benchmark
468
+ <span class="linenos">2</span>node ../../cnoke/cnoke.js --prefer-clang
477
469
  </pre></div>
478
470
  </div>
479
- <p>Once this is done, you can execute each implementation, e.g. <code class="docutils literal notranslate"><span class="pre">build/raylib_cc</span></code> or <code class="docutils literal notranslate"><span class="pre">node</span> <span class="pre">./atoi_koffi.js</span></code>. You can optionally define a custom number of iterations, e.g. <code class="docutils literal notranslate"><span class="pre">node</span> <span class="pre">./atoi_koffi.js</span> <span class="pre">10000000</span></code>.</p>
480
- <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>node ./atoi_napi.js
481
- node ./atoi_koffi.js
471
+ <p>Once everything is built and ready, run:</p>
472
+ <div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="linenos">1</span>node benchmark.js
482
473
  </pre></div>
483
474
  </div>
484
475
  </section>
@@ -542,19 +533,17 @@ node ./atoi_koffi.js
542
533
  <div class="toc-tree">
543
534
  <ul>
544
535
  <li><a class="reference internal" href="#">Benchmarks</a><ul>
545
- <li><a class="reference internal" href="#rand-results">rand results</a><ul>
546
- <li><a class="reference internal" href="#linux-x86-64">Linux x86_64</a></li>
547
- <li><a class="reference internal" href="#windows-x86-64">Windows x86_64</a></li>
548
- </ul>
549
- </li>
550
- <li><a class="reference internal" href="#atoi-results">atoi results</a><ul>
551
- <li><a class="reference internal" href="#id1">Linux x86_64</a></li>
552
- <li><a class="reference internal" href="#id2">Windows x86_64</a></li>
536
+ <li><a class="reference internal" href="#overview">Overview</a></li>
537
+ <li><a class="reference internal" href="#linux-x86-64">Linux x86_64</a><ul>
538
+ <li><a class="reference internal" href="#rand-results">rand results</a></li>
539
+ <li><a class="reference internal" href="#atoi-results">atoi results</a></li>
540
+ <li><a class="reference internal" href="#raylib-results">Raylib results</a></li>
553
541
  </ul>
554
542
  </li>
555
- <li><a class="reference internal" href="#raylib-results">Raylib results</a><ul>
556
- <li><a class="reference internal" href="#id3">Linux x86_64</a></li>
557
- <li><a class="reference internal" href="#id4">Windows x86_64</a></li>
543
+ <li><a class="reference internal" href="#windows-x86-64">Windows x86_64</a><ul>
544
+ <li><a class="reference internal" href="#id1">rand results</a></li>
545
+ <li><a class="reference internal" href="#id2">atoi results</a></li>
546
+ <li><a class="reference internal" href="#id3">Raylib results</a></li>
558
547
  </ul>
559
548
  </li>
560
549
  <li><a class="reference internal" href="#running-benchmarks">Running benchmarks</a></li>
@@ -5,7 +5,7 @@
5
5
  <meta name="color-scheme" content="light dark"><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
6
6
  <link rel="index" title="Index" href="genindex" /><link rel="search" title="Search" href="search" /><link rel="prev" title="Contributing" href="contribute" />
7
7
 
8
- <meta name="generator" content="sphinx-5.0.1, furo 2022.06.04.1"/>
8
+ <meta name="generator" content="sphinx-5.0.2, furo 2022.06.21"/>
9
9
  <title>Changelog - Koffi</title>
10
10
  <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
11
11
  <link rel="stylesheet" type="text/css" href="_static/styles/furo.css?digest=40978830699223671f4072448e654b5958f38b89" />
@@ -162,7 +162,7 @@
162
162
  </form>
163
163
  <div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
164
164
  <ul class="current">
165
- <li class="toctree-l1"><a class="reference internal" href="platforms">Supported platforms</a></li>
165
+ <li class="toctree-l1"><a class="reference internal" href="platforms">Requirements</a></li>
166
166
  <li class="toctree-l1"><a class="reference internal" href="start">Quick start</a></li>
167
167
  <li class="toctree-l1"><a class="reference internal" href="types">Data types</a></li>
168
168
  <li class="toctree-l1"><a class="reference internal" href="functions">Function calls</a></li>
@@ -205,6 +205,45 @@
205
205
  <article role="main">
206
206
  <section id="changelog">
207
207
  <h1>Changelog<a class="headerlink" href="#changelog" title="Permalink to this heading">#</a></h1>
208
+ <section id="koffi-1-3-8">
209
+ <h2>Koffi 1.3.8<a class="headerlink" href="#koffi-1-3-8" title="Permalink to this heading">#</a></h2>
210
+ <p><strong>Main changes:</strong></p>
211
+ <ul class="simple">
212
+ <li><p>Prevent callback reuse beyond FFI call</p></li>
213
+ <li><p>Add BTI support for AAarch64 platforms (except Windows)</p></li>
214
+ </ul>
215
+ <p><strong>Other changes:</strong></p>
216
+ <ul class="simple">
217
+ <li><p>Fix and harmonize a few error messages</p></li>
218
+ </ul>
219
+ </section>
220
+ <section id="koffi-1-3-7">
221
+ <h2>Koffi 1.3.7<a class="headerlink" href="#koffi-1-3-7" title="Permalink to this heading">#</a></h2>
222
+ <p><strong>Main fixes:</strong></p>
223
+ <ul class="simple">
224
+ <li><p>Fix crash when using callbacks inside structs</p></li>
225
+ <li><p>Support for null strings in record members</p></li>
226
+ </ul>
227
+ <p><strong>Other changes:</strong></p>
228
+ <ul class="simple">
229
+ <li><p>Add intptr_t and uintptr_t primitive types</p></li>
230
+ <li><p>Add str/str16 type aliases for string/string16</p></li>
231
+ <li><p>Various documentation fixes and improvements</p></li>
232
+ </ul>
233
+ </section>
234
+ <section id="koffi-1-3-6">
235
+ <h2>Koffi 1.3.6<a class="headerlink" href="#koffi-1-3-6" title="Permalink to this heading">#</a></h2>
236
+ <p><strong>Main fixes:</strong></p>
237
+ <ul class="simple">
238
+ <li><p>Fix install error with Node &lt; 15 on Windows (build system bug)</p></li>
239
+ </ul>
240
+ <p><strong>Other changes:</strong></p>
241
+ <ul class="simple">
242
+ <li><p>Detect incompatible Node.js versions when installing Koffi</p></li>
243
+ <li><p>Prebuild with Clang for Windows x64 and Linux x64 binaries</p></li>
244
+ <li><p>Various documentation improvements</p></li>
245
+ </ul>
246
+ </section>
208
247
  <section id="koffi-1-3-5">
209
248
  <h2>Koffi 1.3.5<a class="headerlink" href="#koffi-1-3-5" title="Permalink to this heading">#</a></h2>
210
249
  <p><strong>Main changes:</strong></p>
@@ -361,6 +400,9 @@
361
400
  <div class="toc-tree">
362
401
  <ul>
363
402
  <li><a class="reference internal" href="#">Changelog</a><ul>
403
+ <li><a class="reference internal" href="#koffi-1-3-8">Koffi 1.3.8</a></li>
404
+ <li><a class="reference internal" href="#koffi-1-3-7">Koffi 1.3.7</a></li>
405
+ <li><a class="reference internal" href="#koffi-1-3-6">Koffi 1.3.6</a></li>
364
406
  <li><a class="reference internal" href="#koffi-1-3-5">Koffi 1.3.5</a></li>
365
407
  <li><a class="reference internal" href="#koffi-1-3-4">Koffi 1.3.4</a></li>
366
408
  <li><a class="reference internal" href="#koffi-1-3-3">Koffi 1.3.3</a></li>