Giter Club home page Giter Club logo

Comments (8)

realFlowControl avatar realFlowControl commented on June 16, 2024 1

Hey @TheLevti 👋

your problem looks like a different problem then what the author wrote.
Could you please signup to our public Slack or open a Support Case with us?
If you choose Slack, please ping "Florian Engelhardt" and/or "Bob Weinand"

from dd-trace-php.

TheLevti avatar TheLevti commented on June 16, 2024 1

@TheLevti unrelated question, but what tool do you use to measure memory usage and plot such graphs?

Its datadog's profiler component. Shows you CPU time, wall time, memory allocations etc.

from dd-trace-php.

iNviNho avatar iNviNho commented on June 16, 2024

Oh,

after exchanging

        $tracer = GlobalTracer::get();

to

        $tracer = new Tracer();

memory doesn't increase anymore. I am trying to think now whether it makes sense or not 🤔

from dd-trace-php.

bwoebi avatar bwoebi commented on June 16, 2024

Hey @iNviNho,

Is there something in the internal state of GlobalTracer::get() which is ever-growing? I.e. observing var_dump(GlobalTracer::get()), do you observe some arrays growing or data structures getting more and more nested?

from dd-trace-php.

iNviNho avatar iNviNho commented on June 16, 2024

After we call

GlobalTracer::get()->getRootScope()?->getSpan()->setTag('result', 'OK');
GlobalTracer::get()->getRootScope()?->close();
dump(GlobalTracer::get());

we always get DDTrace\Tracer object with a different object id as with every new message we consume, we create a new Tracer.

DDTrace\Tracer^ {#4063 // app/Console/Commands/LinkMultiSwapTradesCommand.php:91
  -traces: []
  -transport: DDTrace\Transport\Internal^ {#4087}
  -propagators: array:2 [
    "text_map" => DDTrace\Propagators\TextMap^ {#4086
      -tracer: DDTrace\Tracer^ {#4063}
    }
    "http_headers" => DDTrace\Propagators\TextMap^ {#4086}
  ]
  -config: array:3 [
    "service_name" => "cli"
    "enabled" => true
    "global_tags" => []
  ]
  -scopeManager: DDTrace\ScopeManager^ {#4037
    -scopes: []
    -hostRootScopes: array:1 [
      0 => DDTrace\Scope^ {#4047
        -span: DDTrace\Span^ {#4049
          +context: DDTrace\SpanContext^ {#4052
            +traceId: "89806696424059378"
            +spanId: "89806696424059378"
            +parentId: null
            +isDistributedTracingActivationContext: false
            +propagatedPrioritySampling: null
            +origin: null
            +parentContext: null
            +baggageItems: []
          }
          +hasError: false
          #internalSpan: ?
          +internalSpan: DDTrace\RootSpanData {#4048
            +name: "Jobs"
            +resource: "..."
            +service: "..."
            +type: "cli"
            +meta: array:5 [
              "runtime-id" => "52936d31-37bd-414e-a474-8a0842804c58"
              "version" => "0.0.1"
              "command_origin" => "..."
              "result" => "OK"
              "_dd.p.dm" => "-0"
            ]
            +metrics: array:2 [
              "process_id" => 753.0
              "_dd.agent_psr" => 1.0
            ]
            +exception: null
            +id: "89806696424059378"
            +links: []
            +peerServiceSources: []
            +parent: null
            +stack: DDTrace\SpanStack {#4006
              +parent: DDTrace\SpanStack {#1
                +parent: null
                +active: null
              }
              +active: null
            }
            +origin: ? string
            +propagatedTags: []
            +samplingPriority: 1
            +propagatedSamplingPriority: ? int
            +tracestate: ? string
            +tracestateTags: []
            +parentId: ? string
            +traceId: "6602ef6300000000013f0eb6eeceb1f2"
          }
        }
        -scopeManager: DDTrace\ScopeManager^ {#4037}
        -finishSpanOnClose: true
      }
    ]
    -rootContext: null
  }
  -serviceVersion: "0.0.1"
  -environment: ""
  -rootContext: null
}

and the memory keeps increasing until we do

gc_collect_cycles();
gc_mem_caches();

from dd-trace-php.

TheLevti avatar TheLevti commented on June 16, 2024

image

We see that all our daemon deployments slowly climb in memory usage. This screenshot shows a datadog profile of total allocated memory over an hour in one of our service.

from dd-trace-php.

TheLevti avatar TheLevti commented on June 16, 2024

Actually it is related as we investigate the same issue with @iNviNho.

What we have found out is that calling $tracer->reset() after flushing is fixing the memory leak.

Can we maybe have more details about when reset() should be called and whether thats the correct approach?

Why is the tracer accumulating already closed/flushed traces if reset is not called?

This call also allows us to use the global tracer instance as a singleton and not reinstantiate it after each trace.

from dd-trace-php.

rmikalkenas avatar rmikalkenas commented on June 16, 2024

@TheLevti unrelated question, but what tool do you use to measure memory usage and plot such graphs?

from dd-trace-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.