Skip to content

Add Rust SDK #3329

@dreveman

Description

@dreveman

We've implemented a Rust SDK for Perfetto at Rivos that could be upstreamed to the Perfetto repo if there's interest in having that be part of the main repo. This SDK doesn't have to be part of the upstream repo but we think that would be preferred for the following reasons:

  • Rust is an increasingly popular language and having first-class support for it should be a priority.
  • These bindings are implemented on top of the C ABI and use a protozero plugin similar to the C plugin to generate native Rust code for efficient encoding of protos. Having these proto bindings be up to date with latest perfetto release would be ideal.
  • The "-sys" crate support both the usage of an installed shared perfetto library and "vendored" sources. The latter rely on amalgamated source for the C shared library, which is easy to support as part of the perfetto release process.

I'll crate a pull request with the bindings for more detailed review but here are some of the features:

  • Use the C ABI and protos to generate safe bindings.
  • Low level "-sys" crate for raw C ABI bindings.
  • Higher level "perfetto" crate provides a safe interface, uses common Rust patterns, and is recommended for normal usage.
  • "perfetto-derive" crate provides proc-macros to make tracing of function calls even easier. Just tag a function and entry/exit and arguments passed will be traced if a specific track event category is enabled.
  • Public API fully documented, including example usage that is checked at compile time. All unsafe Rust usage is also documented.
  • Includes examples and a comprehensive set of unit tests.

The pull request will have files with Rivos copyright header and doesn't include CI integration but that could be adjusted if we decide to merge this.

@primiano @LalitMaganti

Sub-issues

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