Documentation Source Text

Check-in [9934321f15]
Login

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

Overview
Comment:Rewrite the footprint.html page to use recent measurements.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9934321f15920141b2e3c57429aaa50a4e41dd4305dc7f8930acf3529a101ec4
User & Date: drh 2017-10-09 12:54:13
Context
2017-10-11
18:22
Updates to the change log, including a typo-fix from Ward Willats. check-in: 6239ca41af user: drh tags: trunk
2017-10-09
12:54
Rewrite the footprint.html page to use recent measurements. check-in: 9934321f15 user: drh tags: trunk
12:04
Add the compiler-difference spreadsheet. check-in: a6a543f623 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added images/cc-diff.jpg.

cannot compute difference between binary files

Changes to pages/compile.in.

108
109
110
111
112
113
114





115
116
117
118
119
120
121
....
1109
1110
1111
1112
1113
1114
1115







1116
1117
1118
1119
1120
1121
1122
is removed from the inner loop of the [bytecode engine], helping SQL statements
to run slightly faster.

<li><p><b>[SQLITE_OMIT_SHARED_CACHE]</b>.
Omitting the possibility of using [shared cache] allows many conditionals
in performance-critical sections of the code to be eliminated.  This can
give a noticable improvement in performance.





</ol>

<p>When all of the recommended compile-time options above are used,
the SQLite library will be approximately 3% smaller and use about 5% fewer
CPU cycles.  So these options do not make a huge difference.  But in 
some design situations, every little bit helps.

................................................................................
  [Using the SQLite Unlock Notification Feature] for additional
  information.
}

COMPILE_OPTION {SQLITE_SOUNDEX} {
  This option enables the [soundex() SQL function].
}








COMPILE_OPTION {SQLITE_USE_FCNTL_TRACE} {
  This option causes SQLite to issue extra [SQLITE_FCNTL_TRACE] file controls
  to provide supplementary information to the VFS.  The "vfslog.c" extension
  makes use of this to provide enhanced logs of VFS activity.
}








>
>
>
>
>







 







>
>
>
>
>
>
>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
....
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
is removed from the inner loop of the [bytecode engine], helping SQL statements
to run slightly faster.

<li><p><b>[SQLITE_OMIT_SHARED_CACHE]</b>.
Omitting the possibility of using [shared cache] allows many conditionals
in performance-critical sections of the code to be eliminated.  This can
give a noticable improvement in performance.

<li><p><b>[SQLITE_USE_ALLOCA]</b>.
Make use of alloca() for dynamically allocating temporary stack space for 
use within a single function, on systems that support alloca().  Without
this option, temporary space is allocated from the heap.
</ol>

<p>When all of the recommended compile-time options above are used,
the SQLite library will be approximately 3% smaller and use about 5% fewer
CPU cycles.  So these options do not make a huge difference.  But in 
some design situations, every little bit helps.

................................................................................
  [Using the SQLite Unlock Notification Feature] for additional
  information.
}

COMPILE_OPTION {SQLITE_SOUNDEX} {
  This option enables the [soundex() SQL function].
}

COMPILE_OPTION {SQLITE_USE_ALLOCA} {
  If this option is enabled, then the alloca() memory allocator will be
  used in a few situations where it is appropriate.  This results in a slightly
  smaller and faster binary.  The SQLITE_USE_ALLOCA compile-time only only 
  works, of course, on systems that support alloca().
}

COMPILE_OPTION {SQLITE_USE_FCNTL_TRACE} {
  This option causes SQLite to issue extra [SQLITE_FCNTL_TRACE] file controls
  to provide supplementary information to the VFS.  The "vfslog.c" extension
  makes use of this to provide enhanced logs of VFS activity.
}

Changes to pages/footprint.in.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22



23
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123

124
125
126
127
128
129
130
131
132
133
134
135
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
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
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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511







512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635



636
637
638
639
640
641
642




643
644
645
646
647
648










649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
<title>SQLite Library Footprint</title>
<tcl>hd_keywords footprint {library size}</tcl>


<h2 align="center">Size Of The SQLite Library</h2>

<p>
The code space used by the SQLite library depends heavily on 
the target platform, what
compiler and optimization options are used to generate object code,
and which optional features of SQLite are included or omitted from
the build.
This page provides examples of what to expect.
</p>

<p>
SQLite [version 3.7.8] ([dateof:3.7.8])
is less than 350KiB in size on x86 with -Os and
less than 400KiB (409KB) on x64.
The -O2 and -O3 builds are larger, presumably due to loop 
unrolling and function inlining.
</p>




<hr>
<h3>Case 1</h3>





<p><ul>
<li> SuSE Linux 10.1
<li> GCC 4.1.0
<li> SQLite version 3.7.8
<li> x86 (32-bit)
</ul></p>



<table border="1" cellpadding="5" cellspacing="0">
<tr>
<th>Optimization<br>Setting<th>Size<br>(bytes)<th>Run-time<br>(Relative to -O0)




<tr>
<td align="center"> -O0
<td align="right">529765
<td align="center">1.00




<tr>
<td align="center"> -O1
<td align="right">397204
<td align="center">0.71









<tr>
<td align="center"> -Os
<td align="right">333059
<td align="center">0.73

<tr>
<td align="center"> -O2
<td align="right">418161
<td align="center">0.68

<tr>
<td align="center"> -O3
<td align="right">828602
<td align="center">0.66

</table>

<hr>
<h3>Case 2</h3>

<p><ul>
<li> Ubuntu
<li> GCC 4.5.2
<li> SQLite version 3.7.8
<li> x86_64 (64-bit)
</ul></p>




<table border="1" cellpadding="5" cellspacing="0">
<tr>
<th>Optimization<br>Setting<th>Size<br>(bytes)<th>Run-time<br>(Relative to -O0)

<tr>
<td align="center"> -O0
<td align="right">625841
<td align="center">1.00

<tr>
<td align="center"> -O1
<td align="right">455072
<td align="center">0.62

<tr>
<td align="center"> -Os
<td align="right">404201
<td align="center">0.59

<tr>
<td align="center"> -O2
<td align="right">499543
<td align="center">0.53

<tr>
<td align="center"> -O3
<td align="right">678465
<td align="center">0.54

</table>


<hr>
<h3>Case 3</h3>

<p><ul>
<li> Mac OS 10.7.1 (Lion)
<li> GCC 4.2.1 + LLVM
<li> SQLite version 3.7.8
<li> x86_64 (64-bit)
</ul></p>

<table border="1" cellpadding="5" cellspacing="0">
<tr>
<th>Optimization<br>Setting<th>Size<br>(bytes)<th>Run-time<br>(Relative to -O0)

<tr>
<td align="center"> -O0
<td align="right">806598

<td align="center">1.00

<tr>
<td align="center"> -O1
<td align="right">508500
<td align="center">0.61

<tr>
<td align="center"> -Os
<td align="right">481816
<td align="center">0.57

<tr>
<td align="center"> -O2
<td align="right">614346
<td align="center">0.55

<tr>
<td align="center"> -O3
<td align="right">661622
<td align="center">0.55

</table>

<hr>
<tcl>hd_fragment relfootprint relfootprint</tcl>



<h2 align="center">The Effect Of Compile-Time Options On Library Size</h2>






<p>The next study shows the effect that various [compile-time options] for
SQLite have on the size of the resulting library file.  The following 
size figures are computed with an early beta of SQLite version 3.7.9
using GCC version 4.6.1 for X86_64 running on Ubuntu with the -Os option.
Actual sizes and size differences may vary by compiler and system.</p>






<table border="1" cellpadding=4 cellspacing=0>
<tr>
<th valign="bottom">[compile-time options | Compile-Time Option]</th>
<th valign="bottom">Library<br>Footprint</th>
<th valign="bottom">Difference<br>From<br>Baseline</th>
<th valign="bottom">Percentage<br>Difference</th>
</tr>

<tr>
<td>All OMIT options</td>
<td align="right">248363</td>
<td align="right">-155714</td>
<td align="right">-38.536%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_TRIGGER]</td>
<td align="right">382038</td>
<td align="right">-22039</td>
<td align="right"> -5.454%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_WAL]</td>
<td align="right">388281</td>
<td align="right">-15796</td>
<td align="right"> -3.909%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_FLOATING_POINT]</td>
<td align="right">390469</td>
<td align="right">-13608</td>
<td align="right"> -3.368%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_VIRTUALTABLE]</td>
<td align="right">391156</td>
<td align="right">-12921</td>
<td align="right"> -3.198%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_PRAGMA]</td>
<td align="right">391292</td>
<td align="right">-12785</td>
<td align="right"> -3.164%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_FOREIGN_KEY]</td>
<td align="right">393555</td>
<td align="right">-10522</td>
<td align="right"> -2.604%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_AUTOVACUUM]</td>
<td align="right">395589</td>
<td align="right">-8488</td>
<td align="right"> -2.101%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_SUBQUERY]</td>
<td align="right">396313</td>
<td align="right">-7764</td>
<td align="right"> -1.921%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_COMPOUND_SELECT]</td>
<td align="right">396810</td>
<td align="right">-7267</td>
<td align="right"> -1.798%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_EXPLAIN]</td>
<td align="right">397011</td>
<td align="right">-7066</td>
<td align="right"> -1.749%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_DATETIME_FUNCS]</td>
<td align="right">397179</td>
<td align="right">-6898</td>
<td align="right"> -1.707%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_INTEGRITY_CHECK]</td>
<td align="right">397438</td>
<td align="right">-6639</td>
<td align="right"> -1.643%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_ATTACH]</td>
<td align="right">397951</td>
<td align="right">-6126</td>
<td align="right"> -1.516%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_ALTERTABLE]</td>
<td align="right">398344</td>
<td align="right">-5733</td>
<td align="right"> -1.419%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_UTF16]</td>
<td align="right">399069</td>
<td align="right">-5008</td>
<td align="right"> -1.239%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_SHARED_CACHE]</td>
<td align="right">399249</td>
<td align="right">-4828</td>
<td align="right"> -1.195%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_INCRBLOB]</td>
<td align="right">399889</td>
<td align="right">-4188</td>
<td align="right"> -1.036%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_ANALYZE]</td>
<td align="right">400207</td>
<td align="right">-3870</td>
<td align="right"> -0.958%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_AUTHORIZATION]</td>
<td align="right">401002</td>
<td align="right">-3075</td>
<td align="right"> -0.761%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_VACUUM]</td>
<td align="right">401026</td>
<td align="right">-3051</td>
<td align="right"> -0.755%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_PAGER_PRAGMAS]</td>
<td align="right">401168</td>
<td align="right">-2909</td>
<td align="right"> -0.720%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_OR_OPTIMIZATION]</td>
<td align="right">401374</td>
<td align="right">-2703</td>
<td align="right"> -0.669%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_VIEW]</td>
<td align="right">401500</td>
<td align="right">-2577</td>
<td align="right"> -0.638%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_BUILTIN_TEST]</td>
<td align="right">401711</td>
<td align="right">-2366</td>
<td align="right"> -0.586%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_XFER_OPT]</td>
<td align="right">402052</td>
<td align="right">-2025</td>
<td align="right"> -0.501%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_AUTOINCREMENT]</td>
<td align="right">402098</td>
<td align="right">-1979</td>
<td align="right"> -0.490%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_SCHEMA_PRAGMAS]</td>
<td align="right">402312</td>
<td align="right">-1765</td>
<td align="right"> -0.437%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_TRACE]</td>
<td align="right">402369</td>
<td align="right">-1708</td>
<td align="right"> -0.423%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_LOAD_EXTENSION]</td>
<td align="right">402611</td>
<td align="right">-1466</td>
<td align="right"> -0.363%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_AUTOMATIC_INDEX]</td>
<td align="right">402685</td>
<td align="right">-1392</td>
<td align="right"> -0.344%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_LIKE_OPTIMIZATION]</td>
<td align="right">402928</td>
<td align="right">-1149</td>
<td align="right"> -0.284%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_REINDEX]</td>
<td align="right">402975</td>
<td align="right">-1102</td>
<td align="right"> -0.273%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_GET_TABLE]</td>
<td align="right">402999</td>
<td align="right">-1078</td>
<td align="right"> -0.267%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_COMPLETE]</td>
<td align="right">403135</td>
<td align="right">-942</td>
<td align="right"> -0.233%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_TEMPDB]</td>
<td align="right">403200</td>
<td align="right">-877</td>
<td align="right"> -0.217%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_BTREECOUNT]</td>
<td align="right">403301</td>
<td align="right">-776</td>
<td align="right"> -0.192%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_LOCALTIME]</td>
<td align="right">403307</td>
<td align="right">-770</td>
<td align="right"> -0.191%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_COMPILEOPTION_DIAGS]</td>
<td align="right">403309</td>
<td align="right">-768</td>
<td align="right"> -0.190%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_FLAG_PRAGMAS]</td>
<td align="right">403441</td>
<td align="right">-636</td>
<td align="right"> -0.157%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_QUICKBALANCE]</td>
<td align="right">403455</td>
<td align="right">-622</td>
<td align="right"> -0.154%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_CAST]</td>
<td align="right">403457</td>
<td align="right">-620</td>
<td align="right"> -0.153%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_CHECK]</td>
<td align="right">403501</td>
<td align="right">-576</td>
<td align="right"> -0.143%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_MEMORYDB]</td>
<td align="right">403555</td>
<td align="right">-522</td>
<td align="right"> -0.129%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_BLOB_LITERAL]</td>
<td align="right">403619</td>
<td align="right">-458</td>
<td align="right"> -0.113%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS]</td>
<td align="right">403748</td>
<td align="right">-329</td>
<td align="right"> -0.081%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_LOOKASIDE]</td>
<td align="right">403753</td>
<td align="right">-324</td>
<td align="right"> -0.080%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_AUTOINIT]</td>
<td align="right">403759</td>
<td align="right">-318</td>
<td align="right"> -0.079%</td>
</tr>

<tr>
<td>[SQLITE_DISABLE_DIRSYNC]</td>
<td align="right">403782</td>
<td align="right">-295</td>
<td align="right"> -0.073%</td>
</tr>

<tr>







<td>[SQLITE_OMIT_DECLTYPE]</td>
<td align="right">403794</td>
<td align="right">-283</td>
<td align="right"> -0.070%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_DEPRECATED]</td>
<td align="right">403794</td>
<td align="right">-283</td>
<td align="right"> -0.070%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_BETWEEN_OPTIMIZATION]</td>
<td align="right">403929</td>
<td align="right">-148</td>
<td align="right"> -0.037%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_PROGRESS_CALLBACK]</td>
<td align="right">403957</td>
<td align="right">-120</td>
<td align="right"> -0.030%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_TRUNCATE_OPTIMIZATION]</td>
<td align="right">403984</td>
<td align="right">-93</td>
<td align="right"> -0.023%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_TCL_VARIABLE]</td>
<td align="right">404003</td>
<td align="right">-74</td>
<td align="right"> -0.018%</td>
</tr>

<tr>
<td>Baseline SQLite Library Size</td>
<td align="right">404077</td>
<td align="right">0</td>
<td align="right"> 0.000%</td>
</tr>

<tr>
<td>[SQLITE_DISABLE_LFS]</td>
<td align="right">404105</td>
<td align="right">+28</td>
<td align="right"> +0.007%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_IOTRACE]</td>
<td align="right">404108</td>
<td align="right">+31</td>
<td align="right"> +0.008%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_AUTORESET]</td>
<td align="right">404143</td>
<td align="right">+66</td>
<td align="right"> +0.016%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_MEMORY_MANAGEMENT]</td>
<td align="right">404348</td>
<td align="right">+271</td>
<td align="right"> +0.067%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_UPDATE_DELETE_LIMIT]</td>
<td align="right">404780</td>
<td align="right">+703</td>
<td align="right"> +0.174%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_COLUMN_METADATA]</td>
<td align="right">405198</td>
<td align="right">+1121</td>
<td align="right"> +0.277%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_UNLOCK_NOTIFY]</td>
<td align="right">405371</td>
<td align="right">+1294</td>
<td align="right"> +0.320%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_ATOMIC_WRITE]</td>
<td align="right">405426</td>
<td align="right">+1349</td>
<td align="right"> +0.334%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_MEMSYS5]</td>
<td align="right">406290</td>
<td align="right">+2213</td>
<td align="right"> +0.548%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_MEMSYS3]</td>
<td align="right">406927</td>
<td align="right">+2850</td>
<td align="right"> +0.705%</td>
</tr>

<tr>
<td>[SQLITE_OMIT_WSD]</td>
<td align="right">408536</td>
<td align="right">+4459</td>
<td align="right"> +1.104%</td>
</tr>




<tr>
<td>[SQLITE_ENABLE_STAT3]</td>
<td align="right">410352</td>
<td align="right">+6275</td>
<td align="right"> +1.553%</td>
</tr>





<tr>
<td>[SQLITE_ENABLE_RTREE]</td>
<td align="right">422554</td>
<td align="right">+18477</td>
<td align="right"> +4.573%</td>










</tr>

<tr>
<td>[SQLITE_ENABLE_FTS3]</td>
<td align="right">467173</td>
<td align="right">+63096</td>
<td align="right">+15.615%</td>
</tr>

<tr>
<td>[SQLITE_ENABLE_FTS4]</td>
<td align="right">467185</td>
<td align="right">+63108</td>
<td align="right">+15.618%</td>
</tr>
</table>

|





|
|
|
<
<
<



<
<
<
<
<
<
>
>
>

<
<
>
>
>
>

|
<
<
<
<
<
>
>

<
<
<
>
>
>

<
<
<
<
>
>
>

<
<
<
<
>
>
>
>
>
>
>
>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
>
>
>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<

>

<
>
>
>
>
>

<
<
<
<
<
>
>
>
>
>

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
>
>
>
>
>
>
>
|
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
>
>
>

<
<
<
<
<
<
>
>
>
>

<
<
<
<
<
>
>
>
>
>
>
>
>
>
>
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
1
2
3
4
5
6
7
8
9
10



11
12
13






14
15
16
17


18
19
20
21
22
23





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
94
95
96
97
98
99















<title>SQLite Library Footprint</title>
<tcl>hd_keywords footprint {library size} {relfootprint}</tcl>


<h2 align="center">Size Of The SQLite Library</h2>

<p>
The code space used by the SQLite library depends on the target
platform, the compiler, and optimization settings.  These variables
also affect performance.



</p>

<p>






The chart below shows the relative size and performance for SQLite
as of 2017-10-08 for various compilers and optimization settings
as tested on Ubuntu 16.04.3 on x86_64.  General observations:



<ol>
<li><p>
The Clang/LLVM compiler is not competitive with GCC.  Clang-generated
binaries are consistently larger and slower than GCC-generated binaries.

<li><p>





Profile guided optimization (PGO) is not helpful with SQLite.  PGO results
in binaries that are about 1% larger and about 0.33% slower.




<li><p>
GCC-7 generates binaries that are smaller and faster than GCC-5, though
the difference is not that great.





<li><p>
Compiling with GCC and -Os results in a binary that is slightly less 
than 500KB in size.





<li><p>
The only significant design decision that developers need to make is
whether to use -Os (optimize for size) or -O6 (optimize for speed).
The -O6 setting makes binaries that run about 2% or 3% faster, but which
are also 66% larger.  The performance here is measured by counting CPU
cycles using cachegrind.  I-cache misses are not considered in the
analysis.  If I-cache misses are considered, builds with -O6 might not
be any faster than builds with -Os.






















<li><p>




Taking into consideration all of the above, the SQLite developers recommend
compiling SQLite using GCC-7 with the -Os optimization setting.
</ol>

































<hr>














<center>

<img src='images/cc-diff.jpg'>
</center>























</hr>


<h1>Details</h1>


<ul>
<li><p>
Measurements above were conducted using SQLite version 
[https://sqlite.org/src/timeline?c=5594a121bf132a98|5594a121bf132a98] from
2017-10-08.






<li><p>
The only SQLite compile-time option used was [-DSQLITE_ENABLE_MEMSYS5].
The optional [memsys5] memory allocator is used for performance testing
because it gives results that are more repeatable than the library-supplied
malloc()/free() on Ubuntu.

































































































































































































































































































































































<li><p>
Performance can be improved and the size reduced by
enabling [-DSQLITE_THREADSAFE=0],
[-DSQLITE_DEFAULT_MEMSTATUS=0],
[-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1],
[-DSQLITE_LIKE_DOESNT_MATCH_BLOBS],
[SQLITE_MAX_EXPR_DEPTH|-DSQLITE_MAX_EXPR_DEPTH=0],
[-DSQLITE_OMIT_DECLTYPE],






[-DSQLITE_OMIT_DEPRECATED],













[-DSQLITE_OMIT_PROGRESS_CALLBACK],

































































































[-DSQLITE_OMIT_SHARED_CACHE], and




[-DSQLITE_USE_ALLOCA].
All these options together result in about a 3.5% performance increase and
a 3.0% size reduction.







<li><p>
Adding optional features like [-DSQLITE_ENABLE_JSON1],
[-DSQLITE_ENABLE_FTS5], or [-DSQLITE_ENABLE_RTREE] will increase the
size of the library, obviously.






<li><p>
Performance was measured using the
[https://sqlite.org/src/file/test/speedtest1.c|speedtest1.c] utility program,
which attempts to mimic a typical workload for SQLite.  Options to
the test runs are:
<blockquote>
<tt>--shrink-memory --reprepare --stats --heap 10000000 64 --size 5</tt>
</blockquote>
Performance was measured by running speedtest1 using cachegrind and
observing the "I refs" output.
</ul>