diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2022-11-02 16:56:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 16:56:58 +0200 |
commit | 4aeb68234dabbb414a0b0c1599b670c02530b1c5 (patch) | |
tree | 6916cba77e5a278956d6ffec414067fe77174701 | |
parent | a581f2f647e741f7dbdbb8554996cf72b390afb1 (diff) |
Statsd dictionaries should be multi-threaded (#13938)
* the new dictionaries do not support concurrent use without locks
* update dictionaries readme
-rw-r--r-- | collectors/statsd.plugin/statsd.c | 7 | ||||
-rw-r--r-- | libnetdata/dictionary/README.md | 9 |
2 files changed, 1 insertions, 15 deletions
diff --git a/collectors/statsd.plugin/statsd.c b/collectors/statsd.plugin/statsd.c index 42970bc7f3..cb78341a0c 100644 --- a/collectors/statsd.plugin/statsd.c +++ b/collectors/statsd.plugin/statsd.c @@ -20,15 +20,10 @@ // -------------------------------------------------------------------------------------- +// DO NOT ENABLE MULTITHREADING - IT IS NOT WELL TESTED // #define STATSD_MULTITHREADED 1 -#ifdef STATSD_MULTITHREADED -// DO NOT ENABLE MULTITHREADING - IT IS NOT WELL TESTED #define STATSD_DICTIONARY_OPTIONS (DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_ADD_IN_FRONT) -#else -#define STATSD_DICTIONARY_OPTIONS (DICT_OPTION_DONT_OVERWRITE_VALUE | DICT_OPTION_ADD_IN_FRONT | DICT_OPTION_SINGLE_THREADED) -#endif - #define STATSD_DECIMAL_DETAIL 1000 // floating point values get multiplied by this, with the same divisor // -------------------------------------------------------------------------------------------------------------------- diff --git a/libnetdata/dictionary/README.md b/libnetdata/dictionary/README.md index fc7b889fb5..6d7e55392e 100644 --- a/libnetdata/dictionary/README.md +++ b/libnetdata/dictionary/README.md @@ -229,12 +229,3 @@ There are 2 versions of `dfe_start`: 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. PS: DFE is Dictionary For Each. - -## special multi-threaded lockless case - -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. - -This is currently used in statsd: - -- 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`). -- 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`. |