Skip to content

Instantly share code, notes, and snippets.

View billywhizz's full-sized avatar
🤓
always be learning

Andrew Johnston billywhizz

🤓
always be learning
View GitHub Profile
path                                     type   inode                      size                       modified       perm    ver    dev      uid      gid  links suid sgid stky
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
.                                        dir    1                             0       2026-02-28T21:20:27.000Z  rwxrwxr-x    8.1    0.0        0        0      0    0    0    0
dev                                      dir    2                             0       2026-02-28T21:20:27.000Z  rwxrwxr-x    8.1    0.0        0        0      0    0    0    0
dev/null                                 chr    3                             0       2026-02-28T21:20:27.000Z  rw-rw-r--    8.1    1.3        0        0      0    0    0    0
dev/zero                                 chr    4                             0       2026-02-28T21:20:27.000Z  rw-rw-r--    8.1    1.5
  • Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  • #100~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC x86_64 GNU/Linux
$ node async-bench.js 
node_v24.13.1    sync time            time     1537 rate     19514068 rate/core     19514068 ns/iter        51.24 rss     58302464 usr 100.00 sys   0.00 tot 100.00
node_v24.13.1    sync time            time     1514 rate     19814339 rate/core     19814339 ns/iter        50.46 rss     58937344 usr 100.00 sys   0.00 tot 100.00
node_v24.13.1    sync time            time     1473 rate     20361091 rate/core     20361091 ns/iter        49.11 rss     58937344 usr 100.00 sys   0.00 tot 100.00
node_v24.13.1    sync time            time     1451 rate     20674993 rate/core     20883832 ns/iter        48.36 rss     58937344 usr  99.00 sys   0.00 tot  99.00
node_v24.13.1    sync time            time     1479 rate     20270737 rate/core     20270737 ns/iter        49.33 rss     58937344 usr 100.00 sys   0.00 tot 100.00
function getDatabase (name = 'ConversationsDatabase') {
const req = window.indexedDB.open(name)
return new Promise((resolve, reject) => {
req.onsuccess = e => resolve(req.result)
req.onerror = req.onabort = reject
})
}
function getAllKeys (db, collection = 'conversations') {
const req = db.transaction([collection], 'readonly').objectStore(collection).getAllKeys()
@billywhizz
billywhizz / Dockerfile
Last active February 21, 2026 14:32
small node.js SEA build
FROM scratch
ADD sea /sea
CMD ["/sea"]
kevent with timeout = 0
rate 80986.22 nanos_op 12347
rate 81772.37 nanos_op 12229
rate 81650.72 nanos_op 12247
rate 81608.60 nanos_op 12253
rate 81304.12 nanos_op 12299
kevent64 with timeout = 0 and flags = 0
rate 81713.43 nanos_op 12237
rate 81648.45 nanos_op 12247

issue summary

  • setImmediate in node.js has a lot of overhead on macos compared to linux. attention was drawn to this in this tweet from jarred sumner.
  • in the referenced benchmark, node on macos was only able to achieve 80k ticks per second of the event loop versus millions per second for Bun & Deno on macos
  • on linux, difference between node, Bun and Deno are much less significant
  • the change implemented in Bun for MacOS uses the KEVENT_FLAG_IMMEDIATE flag to create a fast return from the syscall when there is no pending io.
  • the flag in question is only available when using the kevent64 syscall on macos
  • libuv uses the kevent syscall, which is common across bsd based platforms.
  • i built a version of node with [patches](https://github.com
@billywhizz
billywhizz / microgpt.py
Created February 14, 2026 21:27 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
import { api } from 'lib/sqlite/api.js'
import { bindall, bind_custom } from 'lib/ffi.js'
import { Bench } from 'lib/bench.js'
const { assert, core, ptr, utf8_length } = lo
const { dlopen, RTLD_NOW, RTLD_LOCAL } = core
const sqlite_handle = assert(dlopen(lo.getenv('SQLITE_SO') || 'libsqlite3.so', RTLD_NOW | RTLD_LOCAL))
const sqlite = bindall(api, sqlite_handle)
const u32 = ptr(new Uint32Array(2))

Configuring a development environment for Bun can take 10-30 minutes depending on your internet connection and computer speed. You will need ~10GB of free disk space for the repository and build artifacts.

If you are using Windows, please refer to this guide

Using Nix (Alternative)

A Nix flake is provided as an alternative to manual dependency installation:

nix develop