The real engine
FBSimCity is a model. It parses no SQL and runs no Firebird code — that has been the honest caveat on every page of it. This page is where you can go and check the model against the thing itself.
← back to the cityThe city — a model
Scaled mechanics for intuition. Buffer counts in the dozens, version chains capped at 26, gbak in twelve seconds. Nothing here executes SQL; the particles are an animation over an arithmetic model of the engine's behaviour.
Below — the actual engine
Electric
Firebird compiles Firebird's embedded engine to WebAssembly, the way
PGlite does for PostgreSQL. That is real libfbembed, running
locally in a Web Worker with IndexedDB for storage. No server, and
nothing you type is uploaded anywhere.
The machine room runs the engine on a page of this site, with guided sequences that end in a number you can compare against something the city draws. The Electric Firebird demo is the same engine with the project's own console around it.
How it runs without cross-origin isolation. v0.8.0
claimed the engine could not be embedded here at all because Firebird's
threaded build needed SharedArrayBuffer and
COOP/COEP headers that GitHub Pages does not send.
v0.9.0 solved that with a service worker that synthesised the headers at the
price of a reload on the first visit. Electric Firebird (firebird-wasm
0.20, with Firebird 5.0 LTS & 6.0 WASM builds) now compiles a
single-threaded build (firebird-embedded-st)
alongside the threaded one: on GitHub Pages the worker loads the
single-threaded engine directly, needing no SharedArrayBuffer,
no service worker, and no reload.
Check the model against it
The city makes claims. Here are some you can settle for yourself in a few seconds each — the machine room runs all of these for you and shows what the answer means.
| What the city shows | Ask the real engine |
|---|---|
| The Transaction Hall stamps a new id per transaction, and the OIT trails behind. | SELECT CURRENT_TRANSACTION FROM RDB$DATABASE; — run it
twice and watch the number move, or inspect db.databaseInfo()
(IAttachment::getInfo) at the top of the machine room. |
The Compiler & Optimizer sends indexed filters to the B-Tree
Gardens and unindexed ORDER BY queries to the Sort Yard. |
await db.explain(sql, { detailed: true }) — reads
IStatement::getPlan (PLAN (... INDEX ...) vs
PLAN SORT (... NATURAL)) without executing the query. |
| The Metadata Library is just more tables inside the database file. | SELECT RDB$RELATION_NAME FROM RDB$RELATIONS; — the
catalog is queryable like anything else. |
| An UPDATE writes a new record version rather than overwriting. | MON$RECORD_STATS: update a row twice, then read
MON$BACKVERSION_READS and MON$RECORD_PURGES.
The engine counts the older versions it walked past, and the ones
garbage collection removed. (Reading the old value from a second
attachment shows the same thing, but the browser build has only one.) |
| Firebird has no write-ahead log; the database is one file. | There is no WAL directory to look for. Recovery is careful write ordering, not log replay. |
Where the model is knowingly wrong
Everything the city simplifies is written down in the knob audit, including the direction of each divergence — the places it is kinder than Firebird and the places it is harsher. If the real engine disagrees with the city about something that is not on that list, that is a bug worth reporting:
This has happened. The whole replication model was rewritten in v0.6.1 after a Firebird core developer pointed out that a synchronous replica which dies does not hang commits — it stops replicating and lets them through.
Running it yourself
Electric Firebird works in Node as well as the browser:
const db = new FirebirdBrowser('mydb', {
worker: new Worker('/firebird-engine-worker.js')
});
await db.exec('CREATE TABLE items (id INTEGER PRIMARY KEY, name VARCHAR(100))');
const rows = await db.query('SELECT * FROM items WHERE id = ?', [1]);
const plan = await db.explain('SELECT * FROM items WHERE id = ?', { detailed: true });
const info = await db.databaseInfo();
const schema = await db.introspect();
await db.sweep();
Source and docs: github.com/mariuz/electric-firebird. FBSimCity does not bundle the engine: the machine room loads it from Electric Firebird's published build at the same origin, and 9 MB of WebAssembly stays out of this repository. The city itself is untouched by all of this — it is still a single static page that makes no network calls at all.
Part of FBSimCity. FBSimCity is an independent educational project, not affiliated with or endorsed by the Firebird Project. Firebird® is a registered trademark of the Firebird Foundation Incorporated.