Commit d5f29b8
committed
measure(diagnostics): instrument the batch INSERT and the delete fast path; attribute DELETE (index-maint 82%)
Items 2 and 3 of the agreed sequence (plus 4: AesGcmEncryption parity).
Item 3 - the §2 profiler had a blind spot that cost two rounds of ad-hoc probes: the batch INSERT path had NO
stamps at all, and the fixed-width bulk-delete fast path bypasses DeleteRecordsCore, so a 10K-row DELETE
recorded nothing while 100% of its wall time happened there. Added:
- Table.InsertBatch: Validate (covers validation + serialization) and RowLocate (batch PK probes);
- the fixed-width bulk-delete fast path: RowLocate (contiguous span read), IndexMaintenance (PK DeleteBulk +
every loaded hash index), EngineWrite (tombstone / commit-time buffer).
Still uncovered and recorded in the plan: the bulk UPDATE path's index-maintenance block and the SQL/engine
overhead outside the table (parse, plan cache, commit) - which is why a stage report's total is not wall time.
Item 2 - DELETE attributed (10K by PK, 50K rows, one batch transaction):
arm ops/s wall us/row in stages uninstrumented
plaintext + idx_docs_name 103,495 9.66 4.29 5.37
at-rest + idx_docs_name 100,209 9.98 5.15 4.83
at-rest, no index 140,489 7.12 4.01 3.11
Stage shares at-rest: index-maintenance 81.9%, row-locate 16.3%, engine-write (the tombstone) 1.8%.
So DELETE carries NO at-rest tax (1.03x) and the plan's expected culprit (the tombstone) is noise: the cost is
index maintenance, paid per loaded index per row - the delete decodes each indexed column out of the
fixed-width record, which for TEXT means an overflow-arena read (and a decrypt at-rest), purely to compute the
hash key. The lever is therefore bulk/deferred index removal (DeferredIndexUpdater exists), not a cheaper
delete. Recorded in plan section 7 so Phase 5 is planned against the right cause.
Item 4 - AesGcmEncryption (DatabaseFile / PageEncryption / single-file provider) had the same per-call defect
as CryptoService: a fresh AesGcm + OS-CSPRNG nonce per page/blob operation. Now one cipher per instance (they
are long-lived holders) and [random prefix(8)][counter(4)] nonces, throwing instead of wrapping the invocation
field; Dispose releases the cached cipher so reuse-after-dispose cannot encrypt with the pre-clear key.
AesGcmEncryptionNonceTests pins round-trips (array + span + page APIs), nonce uniqueness with the counter
sequence, concurrency of ONE instance (never measured in this project before), and page nonce uniqueness.
Gate: SharpCoreDB.slnx 0 errors; SharpCoreDB.Tests 1857 total / 0 failed / 16 skipped (+4 tests).
Docs: plan section 7 (DELETE measurement + instrumentation coverage) and CHANGELOG Performance.1 parent eaeb30f commit d5f29b8
5 files changed
Lines changed: 286 additions & 10 deletions
File tree
- docs
- performance
- src/SharpCoreDB
- DataStructures
- Services
- tests/SharpCoreDB.Tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1073 | 1073 | | |
1074 | 1074 | | |
1075 | 1075 | | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
1076 | 1104 | | |
1077 | 1105 | | |
1078 | 1106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
258 | 259 | | |
259 | 260 | | |
260 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
261 | 266 | | |
262 | | - | |
| 267 | + | |
| 268 | + | |
263 | 269 | | |
264 | 270 | | |
| 271 | + | |
265 | 272 | | |
| 273 | + | |
266 | 274 | | |
267 | 275 | | |
268 | 276 | | |
| |||
2675 | 2683 | | |
2676 | 2684 | | |
2677 | 2685 | | |
| 2686 | + | |
2678 | 2687 | | |
2679 | 2688 | | |
| 2689 | + | |
2680 | 2690 | | |
2681 | 2691 | | |
2682 | 2692 | | |
| |||
2687 | 2697 | | |
2688 | 2698 | | |
2689 | 2699 | | |
| 2700 | + | |
2690 | 2701 | | |
2691 | 2702 | | |
2692 | 2703 | | |
| |||
2727 | 2738 | | |
2728 | 2739 | | |
2729 | 2740 | | |
| 2741 | + | |
| 2742 | + | |
2730 | 2743 | | |
2731 | 2744 | | |
2732 | 2745 | | |
| |||
2744 | 2757 | | |
2745 | 2758 | | |
2746 | 2759 | | |
| 2760 | + | |
2747 | 2761 | | |
2748 | 2762 | | |
2749 | 2763 | | |
2750 | 2764 | | |
| 2765 | + | |
| 2766 | + | |
2751 | 2767 | | |
2752 | 2768 | | |
2753 | 2769 | | |
2754 | 2770 | | |
| 2771 | + | |
2755 | 2772 | | |
| 2773 | + | |
2756 | 2774 | | |
2757 | 2775 | | |
2758 | 2776 | | |
| |||
4042 | 4060 | | |
4043 | 4061 | | |
4044 | 4062 | | |
| 4063 | + | |
| 4064 | + | |
| 4065 | + | |
4045 | 4066 | | |
| 4067 | + | |
4046 | 4068 | | |
4047 | 4069 | | |
4048 | 4070 | | |
| |||
4052 | 4074 | | |
4053 | 4075 | | |
4054 | 4076 | | |
| 4077 | + | |
4055 | 4078 | | |
4056 | 4079 | | |
4057 | 4080 | | |
| |||
4099 | 4122 | | |
4100 | 4123 | | |
4101 | 4124 | | |
| 4125 | + | |
| 4126 | + | |
4102 | 4127 | | |
4103 | 4128 | | |
4104 | 4129 | | |
4105 | 4130 | | |
| 4131 | + | |
4106 | 4132 | | |
4107 | 4133 | | |
4108 | 4134 | | |
4109 | 4135 | | |
| 4136 | + | |
| 4137 | + | |
4110 | 4138 | | |
4111 | 4139 | | |
4112 | 4140 | | |
4113 | 4141 | | |
| 4142 | + | |
4114 | 4143 | | |
| 4144 | + | |
4115 | 4145 | | |
4116 | 4146 | | |
4117 | 4147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
25 | 94 | | |
26 | 95 | | |
27 | 96 | | |
| |||
154 | 223 | | |
155 | 224 | | |
156 | 225 | | |
157 | | - | |
| 226 | + | |
158 | 227 | | |
159 | 228 | | |
160 | 229 | | |
161 | 230 | | |
162 | | - | |
| 231 | + | |
163 | 232 | | |
164 | 233 | | |
165 | 234 | | |
| |||
213 | 282 | | |
214 | 283 | | |
215 | 284 | | |
216 | | - | |
| 285 | + | |
217 | 286 | | |
218 | 287 | | |
219 | 288 | | |
| |||
257 | 326 | | |
258 | 327 | | |
259 | 328 | | |
260 | | - | |
| 329 | + | |
261 | 330 | | |
262 | 331 | | |
263 | 332 | | |
264 | 333 | | |
265 | | - | |
| 334 | + | |
266 | 335 | | |
267 | 336 | | |
268 | 337 | | |
| |||
338 | 407 | | |
339 | 408 | | |
340 | 409 | | |
341 | | - | |
| 410 | + | |
342 | 411 | | |
343 | 412 | | |
344 | 413 | | |
| |||
375 | 444 | | |
376 | 445 | | |
377 | 446 | | |
378 | | - | |
| 447 | + | |
379 | 448 | | |
380 | 449 | | |
381 | 450 | | |
382 | 451 | | |
383 | | - | |
| 452 | + | |
384 | 453 | | |
385 | 454 | | |
386 | 455 | | |
| |||
432 | 501 | | |
433 | 502 | | |
434 | 503 | | |
435 | | - | |
| 504 | + | |
436 | 505 | | |
437 | 506 | | |
438 | 507 | | |
| |||
461 | 530 | | |
462 | 531 | | |
463 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
464 | 537 | | |
465 | 538 | | |
| 539 | + | |
| 540 | + | |
466 | 541 | | |
467 | 542 | | |
0 commit comments