These are chat archives for HdrHistogram/HdrHistogram

24th
Mar 2015
D Corbacho
@dcorbacho
Mar 24 2015 10:41
@darach Is it possible to create more than one histogram in the same Erlang node? All the calls to hdr_histogram:open/2 return the same reference
Darach Ennis
@darach
Mar 24 2015 12:24
@dcorbacho Yes you can. NIF resources look like empty binaries to the naked eye or REPL but the VM knows they are different. So they look the same but are different. Here's an example: https://gist.github.com/darach/f3e25fbfae5bafa20994. So as long as you manage the references you can have more than one active at a time in a process. Make sure you close them eventually though so you can reclaim resources allocated against them eventually.
Darach Ennis
@darach
Mar 24 2015 12:37
@dcorbacho Oh, although Erlang doesn't preclude sharing NIF allocated resources across processes this shouldn't be done with hdr histogram as it isn't thread safe to do so. As processes can migrate across schedulers this could be problematic if you share the resource with more than one process at a time unless you're very careful!
D Corbacho
@dcorbacho
Mar 24 2015 12:47
Many thanks @darach !
Darach Ennis
@darach
Mar 24 2015 12:48
Happy to help in any way we can @dcorbacho! :)