Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is that possible to optimize binary output? #6

Open
alexzaru opened this issue Jan 26, 2024 · 2 comments
Open

Is that possible to optimize binary output? #6

alexzaru opened this issue Jan 26, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Milestone

Comments

@alexzaru
Copy link

I have successfully compiled and executed the demo client project with TLS on Rust stable version 1.74. When adjusting dependencies such as replacing pretty_env_logger with env_logger (excluding couple morefeatures) and using a minimal subset of Tokio's features, the resulting binary size is still substantial at 2.4 MB for a build after stripping debug symbols.

My target environment is an embedded Linux platform running FreeRTOS, with approximately 18MB of total flash space and around 6-8MB available. The current binary size eating almost 40% of available space, considering the intended simplicity of the MQTT program, akin to a "Hello, world!" equivalent. In the context of Rust binaries, it might not be excessively large, but for my specific use case, it poses challenges. For comparison, the existing MQTT system, written in C using mosquitto, has a total size around 125kB based on pluging.

Reducing the binary size is crucial for me as it necessitates writing four other parts in C if I choose to implement the MQTT components in Rust. While cargo bloat assists in identifying contributing packages, pinpointing specific ones remains challenging. The primary culprits are std (as expected), rustls, and ring, with Tokio following closely. I think there are possibilities to address that.

@alexzaru
Copy link
Author

I propose the following solutions:

  1. Feature-gating additional components, if feasible.
  2. Allowing compatibility with non-Tokio runtimes, such as async-std, smol, etc, or adapting to event loops based on file-descriptors, like Calloop.
  3. Generalizing runtime to be also a pluging, assuming current universal approach

Not sure how hard to implement it but I might help if I understand correct approach

@sigrlami
Copy link
Owner

This is not a typical use case; generalization of runtime is feasible but extremely complex and time-consuming task.

I'll check over the weekend if there are ways to optimize it including your suggestions.

@sigrlami sigrlami self-assigned this Jan 26, 2024
@sigrlami sigrlami added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Jan 26, 2024
@sigrlami sigrlami added this to the v0.7.2 milestone Jan 26, 2024
@sigrlami sigrlami moved this to Backlog in glaze-mq board Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
Status: Backlog
Development

No branches or pull requests

2 participants