ovis
ovis copied to clipboard
ldms_metric_by_name() needs improved implementation
ldms_metric_by_name() currently employs a simple linear search. Because of this, it is currently forbidden for plugins to actually use ldms_metric_by_name() in the critical path. But plugins where a name-to-index number conversion is required by the nature of the data being sampled, ldms_metric_by_name() accomplishes exactly the task required, but the plugin is forbidden to use it and must implement its own more efficient lookup.
It would seem that improving the ldms_metric_by_name() implementation such that it is permitted to be used in the critical path (where required) would help plugins avoid re-implementing the same lookup code repeatedly.
We can certainly do this. It would be relatively trivial to sort the metric names and use bsearch when the in-memory set data is constructed when lookup completes.
Doing it this way would also be backward compatible; newer versions would simply run faster.