Commit cea4c13
authored
fix(sync-service): Pass shape directly to consumer process (#3964)
There may have been a time where we didn't have a loaded shape in the
ShapeCache when starting a consumer and to avoid blocking the ShapeCache
process we moved the shape load into the consumer. But that time has
passed and the shape cache always has the Shape instance available when
launching a consumer, even for resuming a previously suspended consumer.
So instead of making the Consumer process load the shape, just include
it in the launch opts and save a query to the ShapeDb.
Most fetches from the ShapeDb are quick, especially for a new shape
where the info is probably still in the in-memory buffer and so the
fetch is just a copy from ets, but there is a very long tail, especially
under load. If the consumer process is not scheduled immediately the
ShapeDb could have time to move the shape data out of the cache and
flush it to disk, which means the shape load has to go via the disk
which can be hit and miss (pun intended).
This should be an easy win as we're removing this unstable path for new
shapes and reducing the shape fetch from twice to once for resumed
consumers.
I haven't gone through the tests to remove instances of starting a
consumer directly, thus not including the shape, hence the
`Map.get_lazy/3` call which falls back to the old shapedb fetch route.1 parent 8daa822 commit cea4c13
File tree
4 files changed
+19
-1
lines changed- .changeset
- packages/sync-service/lib/electric
- shape_cache
- shapes
4 files changed
+19
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| 361 | + | |
361 | 362 | | |
362 | 363 | | |
363 | 364 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
189 | 198 | | |
190 | 199 | | |
191 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
| |||
0 commit comments