Debian Codegraph @

src/modules/misctest/README

raw
1 The misctest Module
2
3 Andrei Pelinescu-Onciul
4
5 iptelorg GmbH
6
7 Copyright © 2010 iptelorg GmbH
8 __________________________________________________________________
9
10 Table of Contents
11
12 1. Admin Guide
13
14 1. Overview
15 2. Parameters
16
17 2.1. memory (int)
18 2.2. mem_check_content (int)
19 2.3. message (int)
20 2.4. message_data (str)
21 2.5. message_file (str)
22 2.6. lock_threads_mode (int)
23
24 3. Functions
25
26 3.1. mt_mem_alloc(size)
27 3.2. mt_mem_free()
28 3.3. mt_tcp_thread_exec(text)
29 3.4. mt_lock_test(count)
30 3.5. mt_lock_threads(nrthreads)
31 3.6. mt_unlock_threads(nrops)
32
33 4. RPC Commands
34
35 4.1. mt.mem_alloc size [unit]
36 4.2. mt.mem_free [size] [unit]
37 4.3. mt.mem_used [unit]
38 4.4. mt.mem_rnd_alloc min max total [unit]
39 4.5. mt.mem_test_start min max total min_int max_int
40 total_time [unit]
41
42 4.6. mt.mem_test_stop id
43 4.7. mt.mem_test_destroy id
44 4.8. mt.mem_test_destroy_all id
45 4.9. mt.mem_test_list [id] [unit]
46 4.10. mt.lock_test [executions]
47
48 List of Examples
49
50 1.1. Set memory in the config file
51 1.2. Set mem_check_content in the config file
52 1.3. Set mem_check_content at runtime via kamctl
53 1.4. Set message in the config file
54 1.5. Set message_data in the config file
55 1.6. Set message_file in the config file
56 1.7. Set lock_threads_mode in the config file
57 1.8. men_alloc usage
58 1.9. mem_free usage
59 1.10. mt_tcp_thread_exec usage
60 1.11. mt_lock_test usage
61 1.12. mt_lock_threads usage
62 1.13. mt_lock_threads usage
63 1.14. mt.mem_alloc usage
64 1.15. mt.mem_free usage
65 1.16. mt.mem_used usage
66 1.17. mt.mem_rnd_alloc usage
67 1.18. mt.mem_test_start usage
68 1.19. mt.mem_test_stop usage
69 1.20. mt.mem_test_destroy usage
70 1.21. mt.mem_test_destroy_all usage
71 1.22. mt.mem_test_list usage
72
73 Chapter 1. Admin Guide
74
75 Table of Contents
76
77 1. Overview
78 2. Parameters
79
80 2.1. memory (int)
81 2.2. mem_check_content (int)
82 2.3. message (int)
83 2.4. message_data (str)
84 2.5. message_file (str)
85 2.6. lock_threads_mode (int)
86
87 3. Functions
88
89 3.1. mt_mem_alloc(size)
90 3.2. mt_mem_free()
91 3.3. mt_tcp_thread_exec(text)
92 3.4. mt_lock_test(count)
93 3.5. mt_lock_threads(nrthreads)
94 3.6. mt_unlock_threads(nrops)
95
96 4. RPC Commands
97
98 4.1. mt.mem_alloc size [unit]
99 4.2. mt.mem_free [size] [unit]
100 4.3. mt.mem_used [unit]
101 4.4. mt.mem_rnd_alloc min max total [unit]
102 4.5. mt.mem_test_start min max total min_int max_int total_time
103 [unit]
104
105 4.6. mt.mem_test_stop id
106 4.7. mt.mem_test_destroy id
107 4.8. mt.mem_test_destroy_all id
108 4.9. mt.mem_test_list [id] [unit]
109 4.10. mt.lock_test [executions]
110
111 1. Overview
112
113 This is a debugging/test module. It implements functions (both script
114 and rpcs) that can be used to stress the memory allocator or force
115 memory leaks.
116
117 Warning
118
119 This module should never be used in a production environment.
120
121 2. Parameters
122
123 2.1. memory (int)
124 2.2. mem_check_content (int)
125 2.3. message (int)
126 2.4. message_data (str)
127 2.5. message_file (str)
128 2.6. lock_threads_mode (int)
129
130 2.1. memory (int)
131
132 Initialize for memory testing. Set it to 1 to prepare the memory
133 testing.
134
135 Default: 0 (off).
136
137 Example 1.1. Set memory in the config file
138 ...
139 modparam("misctest", "memory", 1)
140 ...
141
142 2.2. mem_check_content (int)
143
144 When doing the tests, check also for the possibility of the memory
145 being overwritten. When activated, the allocated memory will be filled
146 with a special pattern, that will be checked on free.
147
148 Default: 0 (off).
149
150 It can be changed also at runtime, via the rpc interface.
151
152 Example 1.2. Set mem_check_content in the config file
153 ...
154 modparam("misctest", "mem_check_content", 1)
155 ...
156
157 Example 1.3. Set mem_check_content at runtime via kamctl
158 ...
159 $ kamctl rpc cfg.seti misctest mem_check_content 1
160 ...
161
162 2.3. message (int)
163
164 Initialize and perform message testing.
165
166 Default: 0 (off).
167
168 Example 1.4. Set message in the config file
169 ...
170 modparam("misctest", "message", 1)
171 ...
172
173 2.4. message_data (str)
174
175 Set SIP message data for testing.
176
177 Default: NULL (not set).
178
179 Example 1.5. Set message_data in the config file
180 ...
181 modparam("misctest", "message_data", "...")
182 ...
183
184 2.5. message_file (str)
185
186 Set path to file from where to read SIP message data for testing.
187
188 Default: NULL (not set).
189
190 Example 1.6. Set message_file in the config file
191 ...
192 modparam("misctest", "message_file", "/tmp/sip-data.txt")
193 ...
194
195 2.6. lock_threads_mode (int)
196
197 Initialize (1) or not (0) the internal lock for pthreads testing.
198
199 Default: 0 (no initialization).
200
201 Example 1.7. Set lock_threads_mode in the config file
202 ...
203 modparam("misctest", "lock_threads_mode", 1)
204 ...
205
206 3. Functions
207
208 3.1. mt_mem_alloc(size)
209 3.2. mt_mem_free()
210 3.3. mt_tcp_thread_exec(text)
211 3.4. mt_lock_test(count)
212 3.5. mt_lock_threads(nrthreads)
213 3.6. mt_unlock_threads(nrops)
214
215 3.1. mt_mem_alloc(size)
216
217 Allocates size bytes.
218
219 Note
220
221 This is a debugging function for simulating memory leaks or stressing
222 the memory allocator. It should not be used in production setups
223
224 Example 1.8. men_alloc usage
225 ...
226 mem_alloc(1048576); # 1MB
227 ...
228
229 3.2. mt_mem_free()
230
231 Frees all the memory allocated with mem_alloc() up to this point.
232
233 Note
234
235 This is a debugging function for simulating memory leaks or stressing
236 the memory allocator. It should not be used in production setups
237
238 Example 1.9. mem_free usage
239 ...
240 mem_free();
241 ...
242
243 3.3. mt_tcp_thread_exec(text)
244
245 Print the text via the tcp main process threads.
246
247 Note
248
249 This is a debugging function for simulating execution on tcp main
250 process threads. It should not be used in production setups
251
252 Example 1.10. mt_tcp_thread_exec usage
253 ...
254 mt_tcp_thread_exec("request $rm uri $ru");
255 ...
256
257 3.4. mt_lock_test(count)
258
259 Lock and unlock the global lock count times.
260
261 Note
262
263 This is a debugging function for simulating locking and unlocking of
264 global lock. It should not be used in production setups
265
266 Example 1.11. mt_lock_test usage
267 ...
268 mt_lock_test(100000000);
269 ...
270
271 3.5. mt_lock_threads(nrthreads)
272
273 Creates a set of threads that try to use the internal lock (see also
274 lock_threads_mode parameter).
275
276 Note
277
278 This is a debugging function to do locking and unlocking of an internal
279 global lock from threads. It should not be used in production setups.
280
281 Example 1.12. mt_lock_threads usage
282 ...
283 mt_lock_threads("4");
284 ...
285
286 3.6. mt_unlock_threads(nrops)
287
288 Unlock the internal global lock used by mt_lock_threads(). It is done
289 nrops-times.
290
291 Note
292
293 This is a debugging function to do locking and unlocking of an internal
294 global lock from threads. It should not be used in production setups.
295
296 Example 1.13. mt_lock_threads usage
297 ...
298 mt_unlock_threads("4");
299 ...
300
301 4. RPC Commands
302
303 4.1. mt.mem_alloc size [unit]
304 4.2. mt.mem_free [size] [unit]
305 4.3. mt.mem_used [unit]
306 4.4. mt.mem_rnd_alloc min max total [unit]
307 4.5. mt.mem_test_start min max total min_int max_int total_time [unit]
308 4.6. mt.mem_test_stop id
309 4.7. mt.mem_test_destroy id
310 4.8. mt.mem_test_destroy_all id
311 4.9. mt.mem_test_list [id] [unit]
312 4.10. mt.lock_test [executions]
313
314 4.1. mt.mem_alloc size [unit]
315
316 Allocates the specified number of bytes. unit is optional and can be
317 one of:
318 * b - bytes
319 * k - KB
320 * m - MB
321 * g - GB
322
323 Example 1.14. mt.mem_alloc usage
324 $ kamctl rpc mt.mem_alloc 10 k
325
326 4.2. mt.mem_free [size] [unit]
327
328 Frees at least size bytes from the memory allocated by other misctest
329 functions (e.g. mt.mem_alloc).
330
331 size is optional. If missing, everything will be freed.
332
333 unit is optional and can be one of:
334 * b - bytes
335 * k - KB
336 * m - MB
337 * g - GB
338
339 Example 1.15. mt.mem_free usage
340 $ kamctl rpc mt.mem_free 1 m
341
342 4.3. mt.mem_used [unit]
343
344 Returns/displays how many bytes are allocated. The default unit is
345 bytes (for all the possible units see above).
346
347 unit is optional and can be one of:
348 * b - bytes
349 * k - KB
350 * m - MB
351 * g - GB
352
353 Example 1.16. mt.mem_used usage
354 $ kamctl rpc mt.mem_used
355 9221460
356
357 4.4. mt.mem_rnd_alloc min max total [unit]
358
359 Allocates total_size memory, in pieces of random size between min ..
360 max (inclusive). unit is optional and represents the unit for all the
361 given sizes (see above).
362
363 Example 1.17. mt.mem_rnd_alloc usage
364 $ kamctl rpc mt.mem_rnd_alloc 1 64 10240 k
365
366 4.5. mt.mem_test_start min max total min_int max_int total_time [unit]
367
368 Starts a malloc test that will take total_time to execute. Memory
369 allocations will be performed at intervals randomly chosen between
370 min_int and max_int (in ms). Each allocation will have a randomly
371 chosen size between min and max unit bytes. After total unit bytes are
372 allocated, everything is released/freed again and the allocations are
373 restarted. All the times are expressed in milliseconds. unit is
374 optional and represents the unit for all the given sizes (see above).
375
376 Several tests can be run in parallel.
377
378 Returns the test id.
379
380 Example 1.18. mt.mem_test_start usage
381 $ kamctl rpc mt.mem_test_start 15 64 25000 128 1500 3600000 k
382 1
383
384 4.6. mt.mem_test_stop id
385
386 Stops the test identified by id.
387
388 Example 1.19. mt.mem_test_stop usage
389 $ kamctl rpc mt.mem_test_stop 1
390
391 4.7. mt.mem_test_destroy id
392
393 Destroys the test identified by id (besides stopping it, it also frees
394 all the data, including the statistics).
395
396 Example 1.20. mt.mem_test_destroy usage
397 $ kamcmd mt.mem_test_destroy 1
398
399 4.8. mt.mem_test_destroy_all id
400
401 Destroys all the running or stopped tests.
402
403 Example 1.21. mt.mem_test_destroy_all usage
404 $ kamcmd mt.mem_test_destroy_all
405
406 4.9. mt.mem_test_list [id] [unit]
407
408 Returns/displays data about the test identified by id, or if no id is
409 specified, it lists all the tests (running or stopped).
410
411 unit is optional. The default is is bytes (for all the possible units
412 see above).
413
414 Example 1.22. mt.mem_test_list usage
415 $ kamcmd mt.mem_test_list
416 {
417 ID : 2
418 run time (s) : 1471
419 remaining (s): 2128
420 allocations : 1749
421 errors : 24
422 overflows : 2
423 total alloc : 69614530
424 min : 15360
425 max : 65536
426 total : 25600000
427 }
428 {
429 ID : 1
430 run time (s) : 3600
431 remaining (s): 0
432 allocations : 4268
433 errors : 640
434 overflows : 4
435 total alloc : 144220713
436 min : 15360
437 max : 65536
438 total : 29696000
439 }
440
441 4.10. mt.lock_test [executions]
442
443 The mt.lock_test RPC command performs a lock/unlock stress test using a
444 global lock. It is primarily intended for debugging and performance
445 testing of the locking subsystem.
446
447 Usage:
448 kamctl rpc mt.lock_test [executions]
449
450 * executions (integer): Number of times to lock and unlock.
451
452 If the argument is provided, it must be a positive integer. If if the
453 argument is not a positive integer, the command will return an error.
454
455 Example:
456 kamctl rpc mt.lock_test 10000
457
458 This will perform 10,000 lock/unlock operations.