-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Do not refcount Trace instances in TraceItem API #721
Conversation
a8d36ec
to
c270e69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay here, but definitely covers ground I'm not familiar with.
c270e69
to
cbda22e
Compare
Added @jclee as a reviewer and removed myself since he wrote a lot of this originally. |
So, the motivation for the original design was to minimize allocation overhead, if a single trace record needed to pass through several trace handlers, each of which might only examine a portion of the data. I guess this hasn't turned out to be a major concern today, with only a few trace handlers installed. It does mean, though, that an entire copy of the trace data needs to be made on each trace handler invocation, which seems like a pity, for something that is generally request-scoped, or at least pipeline-scoped, so the work done during the trace handler will be proportional to the amount of trace data recorded regardless of what the trace handler is doing... e.g. if it's only being used to collect a few request metrics. But maybe I'm overthinking it... The cost wouldn't be more than was already paid during the trace recording, and we do have safeguards in place to limit the size of the recorded data. If I'm understanding the problem correctly:
Hm... I suppose if we have to make a copy, long-term, it might be more efficient to just pass around something that's a bunch of views onto a single arena allocation, such the allocation and copy can just be done once. Or, perhaps, just a |
We could potentially get around that by following a pattern similar to the new
Maybe? I've not dug in that far on this. There's likely lots of better ways of improving this. |
The underlying io Trace objects are kj heap allocated. They cannot be referenced unprotected by the TraceItem jsg object and we do not want to restrict them to the IoContext lifetime. Instead we'll extract the detail we need on TraceItem creation.
cbda22e
to
787c07e
Compare
The underlying io Trace objects are kj heap allocated. They cannot be referenced unprotected by the TraceItem jsg object and we do not want to restrict them to the IoContext lifetime. Instead we'll extract the detail we need on TraceItem creation.