Commit 9b843f2
committed
perf: add __slots__ to Tablet to eliminate per-instance __dict__
Add __slots__ to the Tablet class, removing the per-instance __dict__
allocation. Tablets are created frequently (one per token range per table)
and are long-lived, so the cumulative memory savings are significant.
Before: 416 bytes/tablet (48 instance + 96 __dict__ + 80 replicas + 192 tuples)
After: 328 bytes/tablet (56 instance + 0 __dict__ + 80 replicas + 192 tuples)
Saving: 88 bytes/tablet (21%)
Scale impact (3 replicas/tablet):
12,800 tablets (100 tables x 128): saves 1.1 MB
128,000 tablets (1000 tables x 128): saves 10.7 MB
256,000 tablets (1000 tables x 256): saves 21.5 MB
Tablet.from_row construction also improves:
Before: 186 ns/call
After: 147 ns/call (1.27x faster, -21%)1 parent 3aa5935 commit 9b843f2
1 file changed
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 18 | + | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
0 commit comments