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

Reduce memory footprint by reducing size of data types #242

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

schungx
Copy link
Contributor

@schungx schungx commented Nov 16, 2024

This PR attempts to reduce the memory footprint of using this crate.

  • String types are changed to Box<str> to save 8 bytes each.
  • The thin-vec crate is used to replace Vec's, saving 16 bytes each.
  • Many large Option's are Boxed
  • Many large types in HashMaps are Boxed

I try to avoid making code-breaking changes, but some return types are changed, such as &Vec<T> to &[T]... in most cases that shouldn't matter. The entire test suite compiles are run without change.

The current API design prevents more involved optimizations without breaking code. For example, returning &bool, &u32 etc. prevents those fields from being replaced by smaller, packed data types like bitflags. A future major version should really change those to return non-references instead.

I have given up on optimizing chart data types because they are simply too tedious, and there shouldn't really be more than a few charts in a typical spreadsheet.

@MathNya
Copy link
Owner

MathNya commented Nov 18, 2024

@schungx
Thank you for the tremendous corrections.
We have no problem with the revisions and will approve them.

@MathNya MathNya merged commit 714a588 into MathNya:master Nov 18, 2024
1 check passed
@schungx
Copy link
Contributor Author

schungx commented Nov 18, 2024

Beware some function signatures have minor subtle differences which may require code changes. Be prepared for some incoming issues on this.

@schungx
Copy link
Contributor Author

schungx commented Nov 18, 2024

When I have time I'll put in #[inline] on all the trivial APIs.

@MathNya
Copy link
Owner

MathNya commented Nov 19, 2024

Noted.
We will include that in the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants