sched-ext / scx

sched_ext schedulers and tools
https://bit.ly/scx_slack
GNU General Public License v2.0
691 stars 48 forks source link

sched_utils: Add log recorder format customization #397

Closed jfernandez closed 11 hours ago

jfernandez commented 1 week ago

This change adds the ability to customize the log recorder format for each metric type. There is a default format that is used if no custom MetricFormatter is provided. This is the same format that was used before this change.

The MetricFormatter should be implemented by the user to customize the format of the log recorder. The LogRecorderBuilder now takes a MetricFormatter as an optional parameter.

Following changes will allow additional customization of the log recorder format, such as how many metrics are logged per line.

jfernandez commented 1 week ago

One more note: I don't expect this LogRecorder to work for every scheduler, even after we enable more custom formatting. I think it's fine to continue to print explicitly to meet personal preferences. The primary goal of introducing metrics-rs is to enable exporting of metrics to backends. The LogRecorder is a nice to have if the format works for you, or you are bootstrapping a new scheduler. It also a good example that others can follow to create customer exporters.

jfernandez commented 3 days ago

Thanks @arighi.

I'm sharing context from the Slack discussion on this topic: @htejun suggested an additional hook that gets all counters in a struct so that you can customize how to group them visually. I think this is a good idea and will implement it in the following PR.