Skip to content

Proposal: optimize for binary size #1425

@Folyd

Description

@Folyd

Comparing to the log crate, tracing is so powerful and elegant. However, tracing also brings more binary size to the application due to the more complex expanded macro codes. I have a simple binary size test against tracing and log.
Here is the source code. For 1k lines of info!("Hello World!"); macro called, tracing is nearly 2x larger binary size than the log (in release mode, w/o strip).

$ ls -l target/release/tracing target/release/log 
-rwxr-xr-x  2 xx  staff   567848 Jun  7 21:35 target/release/log
-rwxr-xr-x  2 xx  staff  1137672 Jun  7 21:36 target/release/tracing

P.S. We recently replaced the log with tracing in our company project. What overwhelmed us is that we got 10 Mib large size than before! 😲

Proposal

Optimize the binary size without comprising the features, elegance, and performance.

I only have few thoughts right now:

  • I don't think the name field of Metadata is useful to the Event, neither the file, line, and module_path are useful to the Span? We really need to share the same Metadata struct for Event and Span?
  • Seems like we have a lot of discusses on whether we deserve the level field for Span, I still in favor of level-less Span. I believe this can reduce the complexity and is beneficial to binary size.

Alternative

Maybe we can have a tracing-lite crate, which is binary size friendly but missing some features?

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