census-instrumentation / opencensus-php

A stats collection and distributed tracing framework
Apache License 2.0
202 stars 83 forks source link

Memory bloat with PDO instrumentation #262

Open asldevi opened 4 years ago

asldevi commented 4 years ago

we're observing a memory bloat with PDO's instrumentation handleStatementExecute method .

If I comment out the following line, which does the instumentation, memory bloat disappears.

opencensus_trace_method('PDOStatement', 'execute', [static::class, 'handleStatementExecute']);

Here's a profile info from blackfire for the same.

Screenshot 2020-09-23 at 9 58 59 AM
MrMage commented 3 years ago

@asldevi are you still encountering this issue, or were you able to work around it?

asldevi commented 3 years ago

@MrMage We've realized that this is not a PDO specific problem, but rather the lib holding spans until the request-response cycle is completed. This is causing memory bloats for requests having large number of spans.

We're working on a solution to export every N spans as they come in, and release the memory, just like other Jaeger clients do. There are few intricacies, though. /cc @ShivamYuvraj