## Rationale
DevTools' `TraceEngine.TraceModel.Model` permanently retains parsed
traces in an internal recordings array (`#traces`). Calling
`engine.resetProcessor()` between runs only resets the underlying
processor and does not clear `#traces`.
Because `engine` was previously instantiated as a module-scoped
singleton, every performance trace recorded or parsed in a session
remained permanently held in heap memory for the lifetime of the
process.
## Changes
- In `src/processors/PerformanceTrace.ts`, instantiate
`DevTools.TraceEngine.TraceModel.Model.createWithAllHandlers()` per
invocation of `parseRawTraceBuffer()`.
- Remove the module-scoped `engine` singleton and the obsolete
`engine.resetProcessor()` call.
- Add a unit test in `tests/trace-processing/parse.test.ts` verifying
that consecutive trace parses construct isolated `Model` instances and
keep internal trace retention bounded at 1.
- Add a profiling regression scenario in
`scripts/profile/scenarios/performance_trace.ts` to guard against memory
retention across consecutive traces during `npm run test:memory`.
This PR introduces the HostBindingAdapter to utilize the functions
usually available to DevTools.
Additionally I moved all the DevTools related files under a `devtools`
directory to better separate the extractor logic.
The patch scripts for DevTools were moved under a function to remove the
side-effect nature of the file.
Now gets called in a the creation of the McpContext (and a before hook
in test.)
This PR prevents license notices being dropped when creating package for
publication.
This can happen when first import in the file is type-only import that
gets removed during build. When there is no empty line between the
license block comment and such import, the comment is treated as related
to the import and gets removed alongside it.
Adding an empty line between copyright notice and the import fixes the
issue.
Co-authored-by: Piotr Paulski <piotrpaulski@chromium.org>
This PR tidies up the code around performance parsing and what we
respond with from our tools. It introduces the ability to have no
Insights from a trace (relatively rare, but can happen), and also adds
more information to the output in the event that something went wrong.
Previously we just logged errors, but if we respond with them here that
will also help users report issues and increase the chances that we can
debug them.