Feed Exchange moves well data between Rogii's platform and Petrel Studio. Before a run, the user picks what to send in two trees: one shows the Petrel Studio project, the other the Rogii project. A project can hold thousands of wells, each with folders and attributes under it. I built both trees in January 2026.
In July, I investigated freezes on projects with about 600,000 nodes. Ticking the root of Well Attributes took 1.3 seconds to show on screen. A few clicks on folders in a row kept the main thread blocked for 18 seconds in total.
Where the time went
The tree was already virtualized and drew only the rows in view. All five causes were in the work that runs around a click.
- Every row in the process list asked whether its process was being saved. To answer, the hook selected the whole variables of the pending save, about 770 KB, and deep-compared them on every mutation cache event. It now selects only the process id.
- TanStack Query keeps unchanged parts of a response by comparing the old and new data. On a 3.5 MB tree payload, that comparison ran on every refetch. I replaced it with structural sharing per field, on top of a deep-equal check that allocates nothing.
- Each tree batched its own clicks for 400 ms and sent its own PATCH, and the regular poll kept refetching the 3.5 MB tree while saves were in flight. Both trees now share one queue: it waits a second after the last click, sends one request at a time with only the latest selection, refetches once per burst, pauses polling while a save is pending, and keeps the Run button disabled until it lands.
- The grouped view (wells × attributes) rebuilt 551,000 leaf id strings on each rebuild. The ids are now computed once, and the check for "fully, partly or not selected" allocates nothing and stops at the first answer.
-
Turning the tree state
into a list of selected ids took about 330 ms, and a root toggle ran it
three times. The result is now cached per payload in a
WeakMap, and the hooks share one selection context.
The same change fixed a smaller bug: after switching projects inside the app, the Rogii tree's store still held the previous project's tree. It is now cleared before the new project loads.
Result
| On a project with about 600,000 nodes | Before | After |
|---|---|---|
| Tick the Well Attributes root, until paint | 1.3 s | 280 ms |
| A sequence of folder clicks, main thread blocked | 18 s | no long tasks |
| Select all 7,155 wells, until paint | not measured | 9 ms |
Benchmarks and tests
-
yarn benchruns Vitest benchmarks for selection on a 7,000-well tree. Older ones from January cover the tree itself: expanding the root of a 500,000-node tree takes about 6 ms. - A Playwright suite clicks through the checkbox logic of both trees in both view modes and checks the PATCH requests that go over the wire.
- In September I went back over the tree unit tests and fixed the ones that could not fail. For each fix I broke the code on purpose and checked that the test caught it.