Oliver Medhurst

@honk.foo

compiling javascript: https://porffor.dev + browser security

Porffor is now self-hosted, meaning it compiles itself with itself! This is made possible by Porffor's new rewrite, reducing its lines of code by >50% and making C output up to 5x more efficient! Here you can see the stats before and after the rewrite for Porffor itself:

Porffor selfhost rewrite graphs, before vs after.

bundle lines 40.4K→24.7K (1.6x smaller)
bundle size 2.4MB→2.0MB (1.2x smaller)

C lines 1.6M→289.0K (5.5x smaller)
C size 70.4MB→12.3MB (5.7x smaller)

debug compile time 5.0s→1.2s (4.1x faster)
release compile time 143.2s→37.1s (3.9x faster)

debug binary size 52.4MB→13.6MB (3.8x smaller)
release binary size 14.1MB→4.6MB (3.1x smaller).

took an interesting route for data structures for rewrite and looks like it is good. hybrid C struct and nanboxing because just nanboxing is far too slow :(

want to change my versioning scheme but screwed myself as npm can't rewind versions. my options are: 1. bypassing this restriction somehow 2. going to 0.1xx.0 3. going to 1.0.0-alpha.x any opinions/ideas?

(very!) early preview for a new experimental threading Porffor api. it enables intentionally low level concurrency to (try to) enable the most efficient communication feasible. here are 1 million threads alive simultaneously using only ~16gb. 16kb/thread, <1us start avg.

A graph with RSS as Y axis and threads as X axis. It increases linearly bottom left to top right. Footer shows: "1.00M threads · 15.9 GB · 16 KB/thread · 0.7 µs/start"

optimized selfhosted porffor binary is now <20mb and only takes ~1 minute to compile (>90% clang). (% change is vs debug binary) still buggy though. also still too big ;)

honk@gosling porffor % ./selfhost compile --release
[384ms] bun selfhosted/build.mjs
[4.43s] ./porf c --gc -d --profile-compiler selfhosted/bundle.js selfhosted/stage1.c
[58.08s] make -j8 -f selfhosted/stage1.split/Makefile

[63.08s] compiled selfhosted/porf
  bundle    37.48K lines (+0.00%)  2.18MB  (+0.00%)
  c         1.644M lines (+0.00%)  73.03MB (+0.00%)
  binary    19.82MB (-63.20%)