The workshop, where everyone says what they’re going to touch
Chapter Five
The Workshop with Many Workbenches
In which jobs run side by side until two of them want the same jar
The workshop had a long row of workbenches and a single sign on the wall: SAY WHAT YOU’LL TOUCH. Every job that came in had to say, up front, exactly which drawers it would look in and which ones it would change.
That sign let the foreman do something clever. Jobs that needed different drawers went to different benches at the same time. The painter painted at bench one while the clockmaker oiled gears at bench two and the ribbon-tier got on with ribbons at bench three. Nobody bumped elbows, and the whole workshop hummed along.
V · The Workshop with Many Workbenches
Drawers, Labels and One Shared Jar
In Solana, the drawers are accounts: records on the ledger that hold data or programs. Every transaction lists the accounts it will use and marks the ones it will write to. Solana’s runtime, Sealevel, uses that list to run transactions that don’t clash at the same time, spread over lots of processor cores.
Then two jobs turned up wanting the marble jar, and both of them wanted to change the count inside. If they’d both done it at once they’d have made a mess, so the foreman had one wait until the other was finished. That’s the rule. Transactions that write to the same account take turns, while jobs that only look in a drawer can share it quite happily.
Mr. Croak had come in to sell everyone “Premium Elbow Room”. He was very disappointed to find the workshop had plenty already.
V · The Workshop with Many Workbenches
Sort the Jobs
The foreman has left you in charge for a minute. Five jobs are waiting by the door, and each one lists the drawers it’s going to change.
Press Run the workshop and the jobs get scheduled in rounds. Anything that doesn’t share a drawer it’s changing runs side by side in the same round. Then change what a job touches and watch the rounds shuffle. Can you fit everything into one round? (Not while two jobs fancy the marble jar.)
When the last bench went quiet, Toly reached into his coat to pay the foreman, and found a pocket he’d never noticed before.
Try it · Run the workshop
- Paint a rocking horse
- Oil the cuckoo clock
- Count the marbles
- Sell marbles to Mr. Croak
- Tie a bow
Toggle the drawers each job will change, then run the workshop.
