System.Data.SQLite
Check-in [d8612b51e0]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enhancements to the stress test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d8612b51e073fe6bfb9bc83f18e2a2825cfbe129
User & Date: mistachkin 2015-07-29 02:57:02
Context
2015-07-29
22:03
Honor the second argument to Math.Round when using LINQ. check-in: 369779a300 user: mistachkin tags: trunk
02:57
Enhancements to the stress test. check-in: d8612b51e0 user: mistachkin tags: trunk
2015-07-27
15:41
Update SQLite core library to the 3.8.11 release. check-in: 9514fcda89 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Tests/stress.eagle.

136
137
138
139
140
141
142
143




144

145
146
147
148
149
150
151
...
152
153
154
155
156
157
158






159
160
161
162
163
164
165
166
167
168
...
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
...
263
264
265
266
267
268
269












270
271
272
273
274
275
276
...
308
309
310
311
312
313
314
315
316
317
318
319



320
321
322
323
324
325
326
...
335
336
337
338
339
340
341



342
343
344
345
346
347
348
349
350
351
352
353



354
355
356
357
358
359
360
...
427
428
429
430
431
432
433












434
435
436
437
438
439
440
....
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
....
1331
1332
1333
1334
1335
1336
1337




























































1338
1339
1340
1341
1342
1343
1344
....
1492
1493
1494
1495
1496
1497
1498

1499
1500
1501
1502
1503

1504
1505
1506
1507
1508
1509
1510

  proc initTest { indicator } {
    set ::eagle_tests(constraints) $::test_constraints
  }

  #############################################################################

  proc delayTest { {extra 0} } {




    after [expr {int((rand() * 1000) + $extra)}]

  }

  #############################################################################

  proc waitTest { indicator } {
    if {![$::event WaitOne $::timeout]} then {
      error [appendArgs "timeout while starting workload #" \
................................................................................
          [expr {[string ordinal $indicator 0] - [string ordinal A 0] + 1}]]
    }
  }

  #############################################################################

  proc showTest { indicator } {






    tputs $::test_channel $indicator
    append ::indicators $indicator
    delayTest $::count(2)
  }

  #############################################################################

  proc doneTest { {indicator ""} } {
    if {[string length $indicator] > 0} then {
      lappend ::status(done) $indicator
................................................................................
      tputs $::test_channel $indicator

      if {![info exists ::failures($indicator)]} then {
        set ::failures($indicator) 0
      }

      incr ::failures($indicator)
      delayTest $::count(2)
    }
  }

  #############################################################################

  proc allocMem { size } {
    if {$::coTaskMem} then {
................................................................................
    #       [return] command in [allocMem].
    #
    object dispose $ptr
  }

  #############################################################################













  proc setupLogging { fileName } {
    if {![info exists ::logListener]} then {
      set ::logListener [object create -alias \
          System.Diagnostics.TextWriterTraceListener $fileName]
    }

    object invoke System.Diagnostics.Trace.Listeners Add $::logListener
................................................................................
  #############################################################################

  #
  # NOTE: Setup the default values for the tunable workload parameters.  Any,
  #       all, or none of these may be overriden via the command line.
  #
  set count(0) 3;         # Workload repeat count (i.e. total full runs).
  set count(1) 5;         # Workload iteration count (i.e. within a run).
  set count(2) 200;       # Workload iteration delay, in milliseconds.
  set count(3) 57;        # Workload "small" data chunk size, in bytes.
  set count(4) 10000;     # Workload "big" data chunk size, in bytes.
  set count(5) 209715200; # Maximum heap memory to exclude at one time.



  set noWorkload [list];  # Workloads to be omitted from the run, by index.
  set priorities [list];  # Dictionary of workload thread priorities.
  set exitOnFail false;   # Halt testing and exit process on test failure?
  set coTaskMem true;     # Use AllocCoTaskMem/FreeCoTaskMem for memory?
  set noTrace false;      # Disable SQLite trace logging to a file?

  #############################################################################
................................................................................
        {-StopOnUnknownOption +IgnoreOnUnknownOption SkipOnUnknownOption} -- \
        [list [list null MustHaveIntegerValue -1 -1 -count0 $count(0)] \
        [list null MustHaveIntegerValue -1 -1 -count1 $count(1)] \
        [list null MustHaveIntegerValue -1 -1 -count2 $count(2)] \
        [list null MustHaveIntegerValue -1 -1 -count3 $count(3)] \
        [list null MustHaveIntegerValue -1 -1 -count4 $count(4)] \
        [list null MustHaveIntegerValue -1 -1 -count5 $count(5)] \



        [list null MustHaveListValue -1 -1 -noWorkload $noWorkload] \
        [list null MustHaveListValue -1 -1 -priorities $priorities] \
        [list null MustHaveBooleanValue -1 -1 -exitOnFail $exitOnFail] \
        [list null MustHaveBooleanValue -1 -1 -coTaskMem $coTaskMem] \
        [list null MustHaveBooleanValue -1 -1 -noTrace $noTrace]] $argv

    set count(0) $options(-count0,value)
    set count(1) $options(-count1,value)
    set count(2) $options(-count2,value)
    set count(3) $options(-count3,value)
    set count(4) $options(-count4,value)
    set count(5) $options(-count5,value)



    set noWorkload $options(-noWorkload,value)
    set priorities $options(-priorities,value)
    set exitOnFail $options(-exitOnFail,value)
    set coTaskMem $options(-coTaskMem,value)
    set noTrace $options(-noTrace,value)
  }

................................................................................
      "---- small chunk size is " $count(3) " byte(s)\n"]

  tputs $test_channel [appendArgs \
      "---- big chunk size is " $count(4) " byte(s)\n"]

  tputs $test_channel [appendArgs \
      "---- maximum excluded heap memory is " $count(5) " byte(s)\n"]













  tputs $test_channel [appendArgs \
      "---- workloads to be skipped... " \
      [expr {[llength $noWorkload] > 0 ? $noWorkload : "none"}] \n]

  tputs $test_channel [appendArgs \
      "---- workloads priority overrides... " \
................................................................................
      set maxSize $::count(5)
      object invoke GC AddMemoryPressure $maxSize
      try {
        for {set index 1} {$index <= $count1} {incr index} {
          if {[catch {
            set size [expr {int(min($maxSize, abs($count3 * $index * 5.0)))}]
            set ptr [allocMem $size]; # throw
            useMem $ptr $size; delayTest $count2
            freeMem $ptr; unset -nocomplain ptr
            showTest P
          } error]} then {
            if {[isExpectedError $error]} then {
              showTest p
            } else {
              failTest p $error
................................................................................
            failTest t $error
          }
        }
      }
      doneTest T
    }] 0]
  }]




























































} -body {
  set workloadNames(all) [array names workload]

  tputs $test_channel [appendArgs \
      "---- there are " [llength $workloadNames(all)] \
      " total workloads, their names are: " $workloadNames(all) \n]

................................................................................
  foreach index(0) [array names thread] {
    if {[info exists thread($index(0))] && \
        [cleanupThread $thread($index(0))]} then {
      unset -nocomplain thread($index(0))
    }
  }


  rename freeMem ""
  rename useMem ""
  rename allocMem ""
  rename failTest ""
  rename doneTest ""

  rename showTest ""
  rename waitTest ""
  rename delayTest ""
  rename initTest ""
  rename isExpectedError ""
  rename formatWorkloadTime ""
  rename formatWorkloadResult ""







|
>
>
>
>
|
>







 







>
>
>
>
>
>


|







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>







 







|
|



>
>
>







 







>
>
>












>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>





>







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
...
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
...
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
...
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
...
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
....
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
....
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
....
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616

  proc initTest { indicator } {
    set ::eagle_tests(constraints) $::test_constraints
  }

  #############################################################################

  proc delayTest { base extra } {
    if {$base < 0} then {
      set base 1000
    }
    if {$base > 0 || $extra > 0} then {
      after [expr {int((rand() * $base) + $extra)}]
    }
  }

  #############################################################################

  proc waitTest { indicator } {
    if {![$::event WaitOne $::timeout]} then {
      error [appendArgs "timeout while starting workload #" \
................................................................................
          [expr {[string ordinal $indicator 0] - [string ordinal A 0] + 1}]]
    }
  }

  #############################################################################

  proc showTest { indicator } {
    showTestWithDelay $indicator -1 $::count(2)
  }

  #############################################################################

  proc showTestWithDelay { indicator base extra } {
    tputs $::test_channel $indicator
    append ::indicators $indicator
    delayTest $base $extra
  }

  #############################################################################

  proc doneTest { {indicator ""} } {
    if {[string length $indicator] > 0} then {
      lappend ::status(done) $indicator
................................................................................
      tputs $::test_channel $indicator

      if {![info exists ::failures($indicator)]} then {
        set ::failures($indicator) 0
      }

      incr ::failures($indicator)
      delayTest -1 $::count(2)
    }
  }

  #############################################################################

  proc allocMem { size } {
    if {$::coTaskMem} then {
................................................................................
    #       [return] command in [allocMem].
    #
    object dispose $ptr
  }

  #############################################################################

  proc releaseMem { size } {
    set nFree 0; set resetOk false; set nLargest 0

    set code [object invoke \
        System.Data.SQLite.SQLiteConnection ReleaseMemory \
        $size true true nFree resetOk nLargest]

    return [list $code $nFree $resetOk $nLargest]
  }

  #############################################################################

  proc setupLogging { fileName } {
    if {![info exists ::logListener]} then {
      set ::logListener [object create -alias \
          System.Diagnostics.TextWriterTraceListener $fileName]
    }

    object invoke System.Diagnostics.Trace.Listeners Add $::logListener
................................................................................
  #############################################################################

  #
  # NOTE: Setup the default values for the tunable workload parameters.  Any,
  #       all, or none of these may be overriden via the command line.
  #
  set count(0) 3;         # Workload repeat count (i.e. total full runs).
  set count(1) 5;         # Workload iteration count (within a run).
  set count(2) 200;       # Workload iteration delay (milliseconds).
  set count(3) 57;        # Workload "small" data chunk size, in bytes.
  set count(4) 10000;     # Workload "big" data chunk size, in bytes.
  set count(5) 209715200; # Maximum heap memory to exclude at one time.
  set count(6) 15;        # Workload auxiliary iteration count (within a run).
  set count(7) 100;       # Workload auxiliary iteration delay (milliseconds).
  set count(8) 5000;      # Workload auxiliary data value (for use by run).
  set noWorkload [list];  # Workloads to be omitted from the run, by index.
  set priorities [list];  # Dictionary of workload thread priorities.
  set exitOnFail false;   # Halt testing and exit process on test failure?
  set coTaskMem true;     # Use AllocCoTaskMem/FreeCoTaskMem for memory?
  set noTrace false;      # Disable SQLite trace logging to a file?

  #############################################################################
................................................................................
        {-StopOnUnknownOption +IgnoreOnUnknownOption SkipOnUnknownOption} -- \
        [list [list null MustHaveIntegerValue -1 -1 -count0 $count(0)] \
        [list null MustHaveIntegerValue -1 -1 -count1 $count(1)] \
        [list null MustHaveIntegerValue -1 -1 -count2 $count(2)] \
        [list null MustHaveIntegerValue -1 -1 -count3 $count(3)] \
        [list null MustHaveIntegerValue -1 -1 -count4 $count(4)] \
        [list null MustHaveIntegerValue -1 -1 -count5 $count(5)] \
        [list null MustHaveIntegerValue -1 -1 -count6 $count(6)] \
        [list null MustHaveIntegerValue -1 -1 -count7 $count(7)] \
        [list null MustHaveIntegerValue -1 -1 -count8 $count(8)] \
        [list null MustHaveListValue -1 -1 -noWorkload $noWorkload] \
        [list null MustHaveListValue -1 -1 -priorities $priorities] \
        [list null MustHaveBooleanValue -1 -1 -exitOnFail $exitOnFail] \
        [list null MustHaveBooleanValue -1 -1 -coTaskMem $coTaskMem] \
        [list null MustHaveBooleanValue -1 -1 -noTrace $noTrace]] $argv

    set count(0) $options(-count0,value)
    set count(1) $options(-count1,value)
    set count(2) $options(-count2,value)
    set count(3) $options(-count3,value)
    set count(4) $options(-count4,value)
    set count(5) $options(-count5,value)
    set count(6) $options(-count6,value)
    set count(7) $options(-count7,value)
    set count(8) $options(-count8,value)
    set noWorkload $options(-noWorkload,value)
    set priorities $options(-priorities,value)
    set exitOnFail $options(-exitOnFail,value)
    set coTaskMem $options(-coTaskMem,value)
    set noTrace $options(-noTrace,value)
  }

................................................................................
      "---- small chunk size is " $count(3) " byte(s)\n"]

  tputs $test_channel [appendArgs \
      "---- big chunk size is " $count(4) " byte(s)\n"]

  tputs $test_channel [appendArgs \
      "---- maximum excluded heap memory is " $count(5) " byte(s)\n"]

  tputs $test_channel [appendArgs \
      "---- workloads will have an auxiliary iteration count of " \
      $count(6) \n]

  tputs $test_channel [appendArgs \
      "---- workloads will have an auxiliary iteration delay of " \
      $count(7) " millisecond(s)\n"]

  tputs $test_channel [appendArgs \
      "---- workloads will have an auxiliary data value of " \
      $count(8) \n]

  tputs $test_channel [appendArgs \
      "---- workloads to be skipped... " \
      [expr {[llength $noWorkload] > 0 ? $noWorkload : "none"}] \n]

  tputs $test_channel [appendArgs \
      "---- workloads priority overrides... " \
................................................................................
      set maxSize $::count(5)
      object invoke GC AddMemoryPressure $maxSize
      try {
        for {set index 1} {$index <= $count1} {incr index} {
          if {[catch {
            set size [expr {int(min($maxSize, abs($count3 * $index * 5.0)))}]
            set ptr [allocMem $size]; # throw
            useMem $ptr $size; delayTest -1 $count2
            freeMem $ptr; unset -nocomplain ptr
            showTest P
          } error]} then {
            if {[isExpectedError $error]} then {
              showTest p
            } else {
              failTest p $error
................................................................................
            failTest t $error
          }
        }
      }
      doneTest T
    }] 0]
  }]

  #############################################################################
  #                              WORKLOAD #21 (U)                             #
  #############################################################################

  set workload(21) [list \
      [list srcFileName dstFileName table count1 count2 count3] {
    #
    # NOTE: Workload #21, rapidly try to release all non-essential memory.
    #
    waitTest U
    lappend ::times(21) [lindex [time {
      initTest U
      for {set index 1} {$index <= $::count(6)} {incr index} {
        if {[catch {
          releaseMem -1
          showTestWithDelay U 0 $::count(7)
        } error]} then {
          if {[isExpectedError $error]} then {
            showTest u
          } else {
            failTest u $error
          }
        }
      }
      doneTest U
    }] 0]
  }]

  #############################################################################
  #                              WORKLOAD #22 (V)                             #
  #############################################################################

  set workload(22) [list \
      [list srcFileName dstFileName table count1 count2 count3] {
    #
    # NOTE: Workload #22, rapidly try to change the default cache size.
    #
    waitTest V
    lappend ::times(22) [lindex [time {
      initTest V
      setupWorkloadFileDb $dstFileName db
      for {set index 1} {$index <= $::count(6)} {incr index} {
        if {[catch {
          sql execute $db [appendArgs \
              "PRAGMA default_cache_size=" \
              [expr {int(rand() * $::count(8))}] \;]
          showTestWithDelay V 0 $::count(7)
        } error]} then {
          if {[isExpectedError $error]} then {
            showTest v
          } else {
            failTest v $error
          }
        }
      }
      cleanupDb $dstFileName db false true false
      doneTest V
    }] 0]
  }]
} -body {
  set workloadNames(all) [array names workload]

  tputs $test_channel [appendArgs \
      "---- there are " [llength $workloadNames(all)] \
      " total workloads, their names are: " $workloadNames(all) \n]

................................................................................
  foreach index(0) [array names thread] {
    if {[info exists thread($index(0))] && \
        [cleanupThread $thread($index(0))]} then {
      unset -nocomplain thread($index(0))
    }
  }

  rename releaseMem ""
  rename freeMem ""
  rename useMem ""
  rename allocMem ""
  rename failTest ""
  rename doneTest ""
  rename showTestWithDelay ""
  rename showTest ""
  rename waitTest ""
  rename delayTest ""
  rename initTest ""
  rename isExpectedError ""
  rename formatWorkloadTime ""
  rename formatWorkloadResult ""