This commit improves the scalability of custom metrics by:
- being optimistic about the existence of a given metric (including labels):
since most of the time a given metric, even with labels, will be increased
more than once, we can take read-only lock and only fallback to taking a
write lock if we actually have to add a new entry. This is especially
useful when using custom metrics with per-thread Lua, since there is no
global lock involved in this case.
- optimizing the "no label" case, since the Lua FFI interface does not
use anyway: skip the creation (and destruction) of an empty labels
map whenever possible, return an empty string early when combining
empty labels.
It already yields a noticeable improvement when a single thread is used,
but really shines when several threads are processing queries simultaneously.