DataDog / dd-trace-rb

Datadog Tracing Ruby Client
https://docs.datadoghq.com/tracing/
Other
299 stars 368 forks source link

Add metrics around GVL #3433

Open beauraF opened 5 months ago

beauraF commented 5 months ago

Since ruby 3.2 there is now an instrumentation API for the GVL. I believe it could be a nice addition to datadog runtime metrics. This should help to understand an application's workload and allow fine-tuning of the number of threads used by web server (see https://github.com/rails/rails/issues/50450, https://github.com/Shopify/gvltools?tab=readme-ov-file#localtimer).

Without going into implementation details, ddtrace could leverage https://github.com/Shopify/gvltools to achieve this?

Happy to hear your thoughts and insights.

ivoanjo commented 5 months ago

Hello there! Thanks for raising this :)

Yes, we agree, very much! I believe it's definitely a question of when, not if, we'll add this. (I gave a whole presentation at RubyKaigi 2023 about our research into this topic)

The path to integrating this will probably be through the Datadog profiler extension, which would enable it to be exposed both as a metric, as well as with deeper integration.

We hope to pick this up sometime later this year, but do very much welcome community contributions, if you're itching too much for this. And if you're interested to talk to us more about this, we can set up a more direct channel as well.

beauraF commented 5 months ago

Hello @ivoanjo!

Yes, we agree, very much! I believe it's definitely a question of when, not if, we'll add this.

That's an awesome news!

I gave a whole presentation at RubyKaigi 2023 about our research into this topic

I'll have a look! Thanks for sharing.

The path to integrating this will probably be through the Datadog profiler extension, which would enable it to be exposed both as a metric, as well as with deeper integration.

If I understand correctly, the idea would be to integrate here, and not rely on GVLTools, right?

but do very much welcome community contributions, if you're itching too much for this

As we are using unicorn in production, that's not our top priority, but I'll see if we can have sometime to make a proposal.

ivoanjo commented 5 months ago

If I understand correctly, the idea would be to integrate here, and not rely on GVLTools, right?

Yes. In fact the work in GVLTools is split between a number of new VM APIs and the gem itself (and they were created by the same person). GVLTools provides a small layer on top of those APIs, and I think we'll probably want to use them directly.

As we are using unicorn in production, that's not our top priority, but I'll see if we can have sometime to make a proposal.

No rush at all! I mostly mentioned it so our plans on this are clear to the wider community :)

vladkosarev commented 4 months ago

This would be pretty amazing!