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.
A correction to what this page said in v0.8.0. It
claimed the engine could not be embedded here at all. The reasoning was
right up to the last step: Firebird's engine uses threads, so the build
needs SharedArrayBuffer, which browsers grant only to a
cross-origin isolated page, and GitHub Pages cannot send the
COOP/COEP headers that grant isolation. What was
missed is that a service worker can synthesise those headers for any
page that ships one — including this project's own — and that both projects
publish to mariuz.github.io, so the engine's assets are
same-origin and need no CORP header to be loaded under
require-corp. The measurement behind the old claim was real: an
iframe did report not isolated. It reported that because the page
doing the framing was not isolated either, which was the part not tested.
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 the first, second and fourth 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. |
| 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, name VARCHAR(100))');
const rows = await db.query('SELECT * FROM items WHERE id = ?', [1]);
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.