Skip to content

Using a circular buffer instead of stopping/starting profiling #81

@mbkv

Description

@mbkv

I recently started experimenting with this API at Kapwing, a modern browser based video editor. We’ve had great success using this to implement a reporting system. We’ve even fixed several bugs within hours of deploying it. Thank you to everyone involved!

The one thing in the spec that confused me is the incredibly short lifetime of Profiler. While I think I understand the reasoning behind this decision, it is also a little confusing. As a user of this API, I would have heavily preferred for Profiler to contain a circular buffer of the previous “maxBufferSize” samples. That way, when we detect a degradation in performance, we can stop the recording, and immediately push it offline for analysis

The current spec however forces us to keep a copy of the previous trace, just in case we need to concatenate them manually. It also generates a lot more garbage than is necessary as there’s no way to predict ahead of time if this trace will end up being “useful”. IE we may decide to issue a report in the 2 seconds after a trace ends. We would not have the the context clues if we just decide to throw away the previous Profiler instance

I’m wondering if this alternative was considered, or if there was a browser limitation that stops this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions