AltSql Realtime · Live demo
A 10 ms deadline, on a chip that takes 45 ms to erase
A controller runs a loop 100 times a second. Every cycle it writes one value, its state or, every tenth cycle, one of its settings, and logs a row, and those writes must be done within 10 ms of the cycle's start. Its flash chip needs 45 ms to erase a sector, and up to 400 ms. AltSql Core erases inside the write that needs the room. AltSql Realtime never erases inside a write, and works out from its configuration the most any write can cost. It erases only when the loop calls idle: here, between cycles, while the chip erases in the background.
Simulated chips, real engines. Both engines run in this page, compiled to WebAssembly, each on its own chip. The chips are emulated in memory, and every operation takes the time the chip's datasheet gives it: typical, or the slowest it allows.
Try this
Loading the engines
Every cycle, from its start to the end of its writes
0.0 sThe last ten seconds of the loop, one point a cycle. The scale goes up in steps of ten, so the 10 ms deadline sits in the middle and an erase shows as a spike. A cycle that starts late, because the one before ran over, counts from when it should have started.
AltSql Core erases inside the write that needs the room
AltSql Realtime erases only in idle, between cycles
What it took
Since the page started, at each of the chip's timings the loop has run at.
What Realtime promises
The limits come from altsql_rt_check, before the store opens; the times are the chip's, worked out from them. The test suite checks every call on its test stores against its limit: none went over, and every kind of call but seeks reached its limit exactly. This loop's writes stay well inside them.
What is real here
Real
- AltSql Realtime and AltSql Core: the prototypes' own code, each on its own emulated chip of 256 KiB, 64 sectors of 4 KiB.
- Every read, program and erase they ask for, counted as they ask for it.
- The power cuts: at a random byte of each engine's next flash work, a write or an erase, or between writes if it is refusing them. A sector being erased is left half erased. Every value and the newest 100 rows each engine acknowledged are read back and checked.
Simulated
- Time. Each operation takes the time the Winbond W25Q32FV datasheet (revision J) gives it, typical or at most: a sector erase 45 ms typical, for the chip's IQ and IF grades, and 400 ms at most. Reads run at 50 MHz. Suspending an erase costs 20 µs, the most the datasheet allows.
- The erase in the background: the demo's flash driver starts an erase and returns, and the chip erases between cycles, suspended while a cycle writes. The datasheet allows reading and programming other sectors during a suspended erase; it does not say whether suspending lengthens the erase, and the demo assumes it does not.
- The loop has run for 80 seconds before the page starts, so both chips are full and rolling over. The page runs many cycles a second.