Closed cluesque closed 1 year ago
👋 @cluesque , did you still observe the memory bloat pattern if you disable Datadog profiling ?
Have you tried the partial flushing approach with enabling tracing.partial_flush.enabled
?
@TonyCTHsu Adding c.tracing.partial_flush.enabled = true
to our initializer did indeed fix the problem, thanks!
Is there a downside to turning that on? (Is there a reason it's not enabled by default?)
Is there a downside to turning that on? (Is there a reason it's not enabled by default?)
Partial flush has a slightly increased total overhead, because performing the bulk serialization of a large trace is cheaper than multiple partial serializations of that same trace. The different shouldn't be too noticeable, though.
Also, in applications with non-trivial sampling rules, the sampling decision can be performed late in the trace lifecycle, but when ddtrace
partial flushes it has to choose a sampling decision at flush time. This can cause partially flushed trace subsets to have a different sampling decision than the final trace. This means it's possible, but unlikely, that your application will send more partial traces than needed to the backend.
In general, this mismatch between the sampling of subsets of the trace and the complete trace are unlikely, but are possible.
But as a general rule, partial flushing works as expected for the vast majority of workflows: we just cannot claim that it is the best solution across the board.
(Since this doesn't appear to be a problem with profiling, I've taken the liberty of updating the ticket title)
I had the same issue and tracing.partial_flush.enabled = true
solved it 🎉
Current behaviour
We have a sidekiq job that loops over rows in a CSV file, using ActiveRecord to insert records into our database.
When we run this over a file with a million records, we find the memory consumption of the sidekiq process to grow dramatically, and will sometimes exhaust the available memory and kill the host.
Debugging with
ObjectSpace
, periodically reporting on the most populous object classes, we find the number ofDatadog::Tracing::Span
objects growing as the process progresses.If we comment out the
c.tracing.instrument :sidekiq
line in ourconfig/initializers/datadog.rb
the memory growth goes away.Expected behaviour
I'm not totally certain this is unexpected behavior. It might be that ddtrace needs to capture data and can't meaningfully free it until the task is complete.
We'd like to have some way of limiting the memory footprint of instrumentation without disabling the feature altogether.
Is there a way of saying "don't instrument this block" perhaps?
Steps to reproduce
How does
ddtrace
help you?Environment
ddtrace version: 1.11.1
Configuration block (
Datadog.configure ...
):Ruby version: 3.0.6
Operating system: Ubuntu 18.04.6
Relevant library versions: Sidekiq 7.1.0