News for hackers. Stuff that matters.
Re:Beware of Bun.js by Jarred on Friday October 14, 2022 @01:18AM (#33199911)
Creator of Bun here.

Regarding the SQLite claim:

The "view source" link for SQLite is out of date (fixing shortly), but the numbers are correct. I forgot to change the label on the landing page from "x/sqlite" to "x/sqlite3" and I forgot to update the source link.

You can see I updated in this git commit:

https://github.com/oven-sh/bun/commit/4b5c9acc72908ba22e3f70...

Here is what it shows for me, but I encourage you to run it on your own computer to see for yourself:

    deno run --unstable -A deno.js
    cpu: Apple M1 Max
    runtime: deno 1.26.1 (aarch64-apple-darwin)

    benchmark                        time (avg)             (min … max)       p75       p99      p995
    ------------------------------------------------------------------- -----------------------------
    SELECT \* FROM "Order"          26.3 ms/iter   (25.06 ms … 29.23 ms)  26.74 ms  29.23 ms  29.23 ms
    SELECT \* FROM "Product"       53.91 µs/iter  (52.17 µs … 317.75 µs)     54 µs  65.63 µs  76.75 µs
    SELECT \* FROM "OrderDetail"  269.41 ms/iter (240.72 ms … 308.82 ms) 279.05 ms 308.82 ms 308.82 ms

    bun bun.js
    [0.26ms] ".env"
    cpu: Apple M1 Max
    runtime: bun 0.2.0 (arm64-darwin)

    benchmark                        time (avg)             (min … max)       p75       p99      p995
    ------------------------------------------------------------------- -----------------------------
    SELECT \* FROM "Order"         14.44 ms/iter   (13.71 ms … 17.82 ms)  14.56 ms  17.82 ms  17.82 ms
    SELECT \* FROM "Product"       34.39 µs/iter    (30.46 µs … 4.55 ms)  32.88 µs   48.5 µs  60.13 µs
    SELECT \* FROM "OrderDetail"  148.17 ms/iter  (144.8 ms … 154.92 ms) 149.85 ms 154.92 ms 154.92 ms
Regarding the FFI benchmark, you can see the commit from today here:

https://github.com/oven-sh/bun/commit/40506e33e73018103bcf08...

It threw an error until I googled "Deno pointer ffi", which mentioned this function https://doc.deno.land/deno/unstable/~/Deno.UnsafePointer and that worked. I assumed that `Deno.UnsafePointer.of` is the expected way to get a pointer to a buffer, but it seems that changing the type to "buffer" is a faster way for this case. Will update the page shortly.

Re:Beware of Bun.js by undefined_void on Friday October 14, 2022 @01:25AM (#33199951)
Thank you for the comment. I'll update the gist with this.
Re:Beware of Bun.js by losfair on Friday October 14, 2022 @06:25AM (#33201674)
Bun's SQLite implementation has correctness issues:

https://github.com/oven-sh/bun/issues/921

https://github.com/oven-sh/bun/pull/1056#pullrequestreview-1...

This makes SQLite transactions no longer serializable (in regard to the schema), and breaks the safety of any kind of external concurrency (e.g. mvSQLite and Litestream).