forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOPTIMIZE
101 lines (65 loc) · 2.27 KB
/
OPTIMIZE
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
This page describes optimization tasks.
general:
scripts for performance and stability testing
testing optimizations (-O2)
profile the code and fix optimization leaks
benchmark first!
== mmap storage ==
Implement as global plugins
Cow: key/keyset for mmap storage [in progress]
allocate everything in keyNew in a single block
then for value/name changes, do malloc/realloc (COW)
Mmap global plugin:
in the get path: resolver-like functionality to check if
mmap files are up-to-date, if they are immediately
return mmaped KeySet
at the end of get path: store everything so that it can
be mmaped the next time
sanity checks for byte order, version, validity...
== lazyness ==
make KeySet lazy (create keys on ksLookup)
make getValue lazy (fetch value on ksLookup)
feature interferes with mmap storage and
might be even slower than mmap
== SEARCH ==
profiler:
search for slow parts
elektraMalloc trace:
reduce elektraMallocs
keySet:
make statistics how many keys typical applications need
be efficient for typical needs
== metadata ==
Because metadata is often the same across many keys we introduced a way to share it.
heap profiling of a large keyset with/without shared metadata
examine "benchmark" again, maybe some more interesting things are hidden there...
== EXCEPTION ==
do not throw exceptions within checker plugins (or fix benchmark)
== OPTIMIZE ==
Key unchanged always checked correctly?
check if anything was really changed making key dirty
optimize a key to use a single elektraMalloc
(under typical circumstances)
have all memory of a Key in a single allocation block
or use internally memory management which can be in mmap?
-> especially useful for keyNew
dynamic memory management:
improve realloc, use srealloc
don't use sprintf, asprintf, strdup, strndup
use only own functions where available
use different compilers, libc too
ksAppend() in O(1)
iconv:
open handles in kdbOpen? (depending on kdbOpen optimization that it is only done when needed)
== OTHER ==
getString in C++
== BENCHMARK TESTS ==
iteration
multiple type checkers overhead?
insertion (dump::serialise)
null ptr checks
many mountpoints
many globbing statements
== DATA STRUCTURES ==
improve memory footprint C structures:
https://www.catb.org/esr/structure-packing/?src=yc