commit | 9cb278aac2fa20a46990bd4dba092d59de210f58 | [log] [tgz] |
---|---|---|
author | Primiano Tucci <primiano@google.com> | Tue Sep 23 19:32:59 2025 +0100 |
committer | GitHub <noreply@github.com> | Tue Sep 23 19:32:59 2025 +0100 |
tree | 8ba984da30ffae3d25eb2a433902ac8be0e122c6 | |
parent | ddd37dabb6f3cb8e3646731b682640591f52751f [diff] |
ui: make QueryResult classes easier to be used by Winscope (#3051) Minor non-functional refactoring: nothing should change in our codebase, but makes our code easier to be reused by Winscope. The goal for Winscope is the following: - Be able to call directly queryStreaming() passing an object that they own which will take the query result raw bytes. - This object that they own will just forward the raw bytes onto a worker they own, where they can decode it. The rough sketch of their code is something like: engine.streamingQuery(winscopeWritableRes, sqlQuery) Where WinscopeWritableRes looks like this: ``` engine.streamingQuery(new ForwardingWritableQueryResult(worker.messagePort), 'SELECT * FROM blah...') export class ForwardingWritableQueryResult implements WritableQueryResult { private _isLastBatch = false; constructor(private port: MessagePort) {} appendResultBatch(resBytes: Uint8Array): void { // 1. Send the raw bytes to the worker that will do the decoding // TODO here you'll have to do something a bit more sophisticated to tell // the message type. Depends on how your worker works. this.port.postMessage(resBytes); // 2. We need to do enough decoding just to extract the isLastBatch const reader = protobuf.Reader.create(resBytes); assertTrue(reader.pos === 0); while (reader.pos < reader.len) { const tag = reader.uint32(); switch (tag >>> 3) { case 3: // batch const batchLen = reader.uint32(); const batchRaw = resBytes.subarray(reader.pos, reader.pos + batchLen); reader.pos += batchLen; this._isLastBatch = this.extractIsLastBatch(batchRaw); break; default: reader.skipType(tag & 7); break; } // switch (tag) } // while (pos < end) } isComplete(): boolean { return this._isLastBatch; } private extractIsLastBatch(batchBytes: Uint8Array) { const reader = protobuf.Reader.create(batchBytes); assertTrue(reader.pos === 0); const end = reader.len; let result = false; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 6: // is_last_batch (boolean). result = !!reader.bool(); break; default: reader.skipType(tag & 7); break; } // switch(tag) } // while (pos < end) return result; } } ```
Perfetto is an open-source suite of SDKs, daemons and tools which use tracing to help developers understand the behaviour of complex systems and root-cause functional and performance issues on client and embedded systems.
It is a production-grade tool that is the default tracing system for the Android operating system and the Chromium browser.
Perfetto is not a single tool, but a collection of components that work together:
Perfetto was designed to be a versatile and powerful tracing system for a wide range of use cases.
ftrace
, allowing you to visualize scheduling, syscalls, interrupts, and custom kernel tracepoints on a timeline.chrome://tracing
. Use it to debug and root-cause issues in the browser, V8, and Blink.We‘ve designed our documentation to guide you to the right information as quickly as possible, whether you’re a newcomer to performance analysis or an experienced developer.
New to tracing? If you're unfamiliar with concepts like tracing and profiling, start here:
Ready to dive in? Our “Getting Started” guide is the main entry point for all users. It will help you find the right tutorials and documentation for your specific needs:
Want the full overview? For a comprehensive look at what Perfetto is, why it's useful, and who uses it, see our main documentation page:
Have questions? Need help?
We follow Google's Open Source Community Guidelines.