@cryptotaxi247 / netdata-1 / commits / 4aeb68234

Statsd dictionaries should be multi-threaded (#13938)

* the new dictionaries do not support concurrent use without locks * update dictionaries readme

Costa Tsaousis committed Nov 2, 2022 at 16:56 UTC 4aeb68234dabbb414a0b0c1599b670c02530b1c5
2 files changed +1 -15
collectors/statsd.plugin/statsd.c
+1 -6
@@ -20,15 +20,10 @@
20
21 // --------------------------------------------------------------------------------------
22
23 +// DO NOT ENABLE MULTITHREADING - IT IS NOT WELL TESTED
24 // #define STATSD_MULTITHREADED 1
25
25 -#ifdef STATSD_MULTITHREADED
26 -// DO NOT ENABLE MULTITHREADING - IT IS NOT WELL TESTED
26 #define STATSD_DICTIONARY_OPTIONS (DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_ADD_IN_FRONT)
28 -#else
29 -#define STATSD_DICTIONARY_OPTIONS (DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_ADD_IN_FRONT | DICT_OPTION_SINGLE_THREADED)
30 -#endif
31 -
27 #define STATSD_DECIMAL_DETAIL 1000 // floating point values get multiplied by this, with the same divisor
28
29 // --------------------------------------------------------------------------------------------------------------------
libnetdata/dictionary/README.md
-9
@@ -229,12 +229,3 @@ There are 2 versions of `dfe_start`:
229 While in the loop, depending on the read or write versions of `dfe_start`, the caller may lookup or manipulate the dictionary. The rules are the same with the unsorted walkthrough callback functions.
230
231 PS: DFE is Dictionary For Each.
232 -
233 -## special multi-threaded lockless case
234 -
235 -Since the dictionary uses a hash table and a double linked list, if the contract between 2 threads is for one to use the hash table functions only (`set`, `get` - but no `del`) and the other to use the traversal ones only, the dictionary allows concurrent use without locks.
236 -
237 -This is currently used in statsd:
238 -
239 -- the data collection thread uses only `get` and `set`. It never uses `del`. New items are added at the front of the linked list (`DICT_OPTION_ADD_IN_FRONT`).
240 -- the flushing thread is only traversing the dictionary up to the point it last traversed it (it uses a flag for that to know where it stopped last time). It never uses `get`, `set` or `del`.