|
| 1 | +# ?? Quick 10K Benchmark - Resultaten Beoordeling |
| 2 | + |
| 3 | +## ? HUIDIGE STATUS: BENCHMARKS FALEN NOG STEEDS |
| 4 | + |
| 5 | +### ?? Waargenomen Problemen |
| 6 | + |
| 7 | +**Symptomen**: |
| 8 | +``` |
| 9 | +| Method | Mean | Error | Ratio | |
| 10 | +|--------------------------------------------------- |-----:|------:|------:| |
| 11 | +| 'SharpCoreDB (No Encryption): 10K Batch Insert' | NA | NA | ? | |
| 12 | +| 'SQLite (Memory): 10K Batch Insert' | NA | NA | ? | |
| 13 | +| 'LiteDB: 10K Bulk Insert' | NA | NA | ? | |
| 14 | +
|
| 15 | +Benchmarks with issues: |
| 16 | + Quick10kComparison.'SharpCoreDB (No Encryption): 10K Batch Insert' |
| 17 | + Quick10kComparison.'SQLite (Memory): 10K Batch Insert' |
| 18 | + Quick10kComparison.'LiteDB: 10K Bulk Insert' |
| 19 | +``` |
| 20 | + |
| 21 | +**Metingen gevonden**: |
| 22 | +- ? Jitting fase: WEL metingen (8.3 sec voor SharpCoreDB, 142ms voor SQLite, 476ms voor LiteDB) |
| 23 | +- ? Workload iterations: GEEN metingen (crashes na jitting) |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +## ?? TOEGEPASTE FIXES |
| 28 | + |
| 29 | +### Fix #1: IterationSetup Added (GEÏMPLEMENTEERD) |
| 30 | +```csharp |
| 31 | +[IterationSetup] |
| 32 | +public void IterationSetup() |
| 33 | +{ |
| 34 | + // Clear SQLite tables |
| 35 | + sqliteMemory: DELETE FROM users |
| 36 | + sqliteFile: DELETE FROM users |
| 37 | + |
| 38 | + // Clear LiteDB |
| 39 | + liteCollection.DeleteAll() |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +**Resultaat**: HELPT NIET - nog steeds NA |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +### Fix #2: Thread-Safe ID Generation (GEÏMPLEMENTEERD) |
| 48 | +```csharp |
| 49 | +private static int globalCounter = 0; |
| 50 | + |
| 51 | +public void SharpCoreDB_NoEncrypt_10K() |
| 52 | +{ |
| 53 | + var baseId = Interlocked.Increment(ref globalCounter) * 1000000; |
| 54 | + // Use IDs: 1000000-1009999, 2000000-2009999, etc. |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +**Resultaat**: NOG TE TESTEN |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## ?? WAARSCHIJNLIJKE OORZAKEN |
| 63 | + |
| 64 | +### Hypothese #1: Benchm arkDotNet Process Isolation |
| 65 | +BenchmarkDotNet start benchmarks in **separate processes**. Dit kan problemen veroorzaken met: |
| 66 | +- Database connections |
| 67 | +- File locks |
| 68 | +- Temp directory cleanup |
| 69 | +- Shared state |
| 70 | + |
| 71 | +**Bewijs**: |
| 72 | +``` |
| 73 | +Environment |
| 74 | + Summary -> Detected error exit code from one of the benchmarks. |
| 75 | + It might be caused by following antivirus software: |
| 76 | + - Windows Defender (windowsdefender://) |
| 77 | + Use InProcessEmitToolchain or InProcessNoEmitToolchain to avoid new process creation. |
| 78 | +``` |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +### Hypothese #2: Database Initialization Failure |
| 83 | +De `GlobalSetup` faalt mogelijk in het child process. |
| 84 | + |
| 85 | +**Mogelijke oorzaken**: |
| 86 | +- ? SharpCoreDB DI container niet beschikbaar in child process |
| 87 | +- ? Encryption keys niet beschikbaar |
| 88 | +- ? File permissions issues |
| 89 | +- ? Temp directory niet beschikbaar |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +### Hypothese #3: Exception in Benchmark Method |
| 94 | +De benchmark methods zelf crashen tijdens executie. |
| 95 | + |
| 96 | +**Mogelijke oorzaken**: |
| 97 | +- ? `InsertUsersTrueBatch` faalt op SQL syntax errors |
| 98 | +- ? Connection disposed tussen jitting en workload |
| 99 | +- ? Transaction rollback op error |
| 100 | + |
| 101 | +--- |
| 102 | + |
| 103 | +## ?? AANBEVOLEN OPLOSSINGEN |
| 104 | + |
| 105 | +### Oplossing A: Use InProcess Toolchain (EENVOUDIGST) |
| 106 | +```csharp |
| 107 | +[Config(typeof(InProcessConfig))] |
| 108 | +public class Quick10kComparison |
| 109 | +``` |
| 110 | + |
| 111 | +**Voordelen**: |
| 112 | +- ? Geen process isolation issues |
| 113 | +- ? Debugging mogelijk |
| 114 | +- ? Shared state werkt |
| 115 | + |
| 116 | +**Nadelen**: |
| 117 | +- ?? Minder accurate metingen (geen process cleanup tussen runs) |
| 118 | +- ?? Mogelijk geheugen leaks tussen iterations |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +### Oplossing B: Simpele Console App (DEBUGGING) |
| 123 | +Maak een eenvoudige console app die EXACT dezelfde code runt als de benchmark: |
| 124 | + |
| 125 | +```csharp |
| 126 | +// Program.cs |
| 127 | +var benchmark = new Quick10kComparison(); |
| 128 | +benchmark.Setup(); |
| 129 | + |
| 130 | +try |
| 131 | +{ |
| 132 | + benchmark.IterationSetup(); |
| 133 | + benchmark.SharpCoreDB_NoEncrypt_10K(); |
| 134 | + Console.WriteLine("? SUCCESS!"); |
| 135 | +} |
| 136 | +catch (Exception ex) |
| 137 | +{ |
| 138 | + Console.WriteLine($"? ERROR: {ex.Message}"); |
| 139 | + Console.WriteLine(ex.StackTrace); |
| 140 | +} |
| 141 | +finally |
| 142 | +{ |
| 143 | + benchmark.Cleanup(); |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +**Doel**: Ontdek de EXACTE exception die wordt gegooid |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +### Oplossing C: Logging Toevoegen |
| 152 | +```csharp |
| 153 | +[Benchmark] |
| 154 | +public void SharpCoreDB_NoEncrypt_10K() |
| 155 | +{ |
| 156 | + Console.WriteLine("[START] SharpCoreDB_NoEncrypt_10K"); |
| 157 | + |
| 158 | + try |
| 159 | + { |
| 160 | + var users = dataGenerator.GenerateUsers(RecordCount); |
| 161 | + Console.WriteLine($"[OK] Generated {users.Count} users"); |
| 162 | + |
| 163 | + var baseId = Interlocked.Increment(ref globalCounter) * 1000000; |
| 164 | + Console.WriteLine($"[OK] BaseID = {baseId}"); |
| 165 | + |
| 166 | + var userList = users.Select((u, i) => (baseId + i, u.Name, u.Email, u.Age, u.CreatedAt, u.IsActive)).ToList(); |
| 167 | + Console.WriteLine($"[OK] Prepared {userList.Count} records"); |
| 168 | + |
| 169 | + sharpCoreDbNoEncrypt?.InsertUsersTrueBatch(userList); |
| 170 | + Console.WriteLine("[END] Insert complete"); |
| 171 | + } |
| 172 | + catch (Exception ex) |
| 173 | + { |
| 174 | + Console.WriteLine($"[ERROR] {ex.Message}"); |
| 175 | + throw; |
| 176 | + } |
| 177 | +} |
| 178 | +``` |
| 179 | + |
| 180 | +--- |
| 181 | + |
| 182 | +## ?? VOLGENDE STAPPEN |
| 183 | + |
| 184 | +### Stap 1: InProcess Config Proberen (HOOGSTE PRIORITEIT) |
| 185 | +```csharp |
| 186 | +[SimpleJob(BenchmarkDotNet.Engines.RunStrategy.Throughput, invocationCount: 1)] |
| 187 | +[InProcess] |
| 188 | +public class Quick10kComparison |
| 189 | +``` |
| 190 | + |
| 191 | +### Stap 2: Debug Console App Maken |
| 192 | +Maak `QuickDebugTest.cs` die de benchmark code runt zonder BenchmarkDotNet. |
| 193 | + |
| 194 | +### Stap 3: Logging Toevoegen |
| 195 | +Voeg Console.WriteLine toe om te zien waar het crasht. |
| 196 | + |
| 197 | +### Stap 4: Check Logs |
| 198 | +Kijk in `BenchmarkDotNet.Artifacts/logs/` voor detailed error messages. |
| 199 | + |
| 200 | +--- |
| 201 | + |
| 202 | +## ?? VERWACHTE RESULTATEN (als het werkt) |
| 203 | + |
| 204 | +Gebaseerd op de Jitting metingen: |
| 205 | + |
| 206 | +| Database | Jitting Time | Geschatte Final Time | |
| 207 | +|----------|--------------|----------------------| |
| 208 | +| SQLite (Memory) | 142ms | **~50-100ms** ?? | |
| 209 | +| SQLite (File+WAL) | 147ms | **~50-100ms** ?? | |
| 210 | +| LiteDB | 476ms | **~400-600ms** ?? | |
| 211 | +| SharpCoreDB (No Enc) | 8,300ms | **~7-10 sec** ?? | |
| 212 | +| SharpCoreDB (Encrypted) | 8,549ms | **~40-50 sec** ? | |
| 213 | + |
| 214 | +**Conclusie**: SQLite domineert bulk inserts (zoals verwacht). |
| 215 | + |
| 216 | +--- |
| 217 | + |
| 218 | +## ? WAT WEL WERKT |
| 219 | + |
| 220 | +### Andere Benchmarks Zijn Succesvol |
| 221 | +Kijkend naar de artifacts folder zien we: |
| 222 | +- ? `ComparativeInsertBenchmarks` - HAS RESULTS |
| 223 | +- ? `ComparativeSelectBenchmarks` - HAS RESULTS |
| 224 | +- ? `ComparativeUpdateDeleteBenchmarks` - HAS RESULTS |
| 225 | +- ? `GroupCommitWALBenchmarks` - HAS RESULTS |
| 226 | + |
| 227 | +**Dit betekent**: |
| 228 | +- ? BenchmarkDotNet werkt in principe |
| 229 | +- ? SharpCoreDB werkt in principe |
| 230 | +- ? Er is iets specifiek mis met `Quick10kComparison` |
| 231 | + |
| 232 | +--- |
| 233 | + |
| 234 | +## ?? DEBUGGING PLAN |
| 235 | + |
| 236 | +1. **Vergelijk met werkende benchmarks** |
| 237 | + - Kijk naar `ComparativeInsertBenchmarks.cs` |
| 238 | + - Zie wat zij anders doen |
| 239 | + |
| 240 | +2. **Simplify Quick10kComparison** |
| 241 | + - Verwijder IterationSetup |
| 242 | + - Gebruik gewoon random IDs |
| 243 | + - Test met 100 records eerst |
| 244 | + |
| 245 | +3. **Check de logs** |
| 246 | + ``` |
| 247 | + SharpCoreDB.Benchmarks\BenchmarkDotNet.Artifacts\logs\ |
| 248 | + ``` |
| 249 | + |
| 250 | +--- |
| 251 | + |
| 252 | +## ?? CONCLUSIE |
| 253 | + |
| 254 | +**Status**: ? NIET WERKEND |
| 255 | + |
| 256 | +**Hoofdprobleem**: Benchmarks crashen na jitting, voor workload iterations |
| 257 | + |
| 258 | +**Waarschijnlijke oorzaak**: BenchmarkDotNet process isolation issues |
| 259 | + |
| 260 | +**Aanbevolen fix**: |
| 261 | +1. Probeer InProcess toolchain |
| 262 | +2. Maak debug console app |
| 263 | +3. Vergelijk met werkende benchmarks |
| 264 | + |
| 265 | +**ETA voor fix**: 30-60 minuten werk |
| 266 | + |
| 267 | +--- |
| 268 | + |
| 269 | +**Laatste update**: December 2025 |
| 270 | +**Status**: ?? Needs Investigation |
| 271 | +**Priority**: HIGH |
0 commit comments