-
Notifications
You must be signed in to change notification settings - Fork 15
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
Various memory optimizations #94
base: main
Are you sure you want to change the base?
Commits on Nov 24, 2024
-
Configuration menu - View commit details
-
Copy full SHA for fb7056b - Browse repository at this point
Copy the full SHA fb7056bView commit details -
feat!: use
Cow
whenever possible instead of owned valuesA lot of strings and arrays used in nftables structures are static, but currently we need to do allocations everywhere using owned String and Vec. Replace them with Cow so we can pass &'static str or &'static [_] whenever possible, while returning owned value when deserializing.
Configuration menu - View commit details
-
Copy full SHA for 7922a4a - Browse repository at this point
Copy the full SHA 7922a4aView commit details -
feat!: reduce stack usage by selectively wrapping large values in Box
This evens out some of the large enums' sizes (e.g. Expression and Statement's) from over 200 bytes to <=144. Further reduction could be done, as this commit only changes the obvious ones for now. Also moves BinaryOperation's Box up one level so it only uses one Box.
Configuration menu - View commit details
-
Copy full SHA for 6f5f339 - Browse repository at this point
Copy the full SHA 6f5f339View commit details -
feat(expr)!: make range fixed-sized array, not slice
Since we only expect two elements from Range, we can just use array instead.
Configuration menu - View commit details
-
Copy full SHA for ec094c7 - Browse repository at this point
Copy the full SHA ec094c7View commit details -
fix(expr)!: revert recursive Cow<[Expression]> back to Vec
This fails to build on 1.65: ``` error[E0277]: the trait bound `[SetItem]: ToOwned` is not satisfied in `Expression` --> src/stmt.rs:245:14 | 245 | pub dev: Option<Expression>, | ^^^^^^^^^^^^^^^^^^ within `Expression`, the trait `ToOwned` is not implemented for `[SetItem]`, which is required by `Expression: Sized` | = help: the trait `ToOwned` is implemented for `[T]` note: required because it appears within the type `Expression` --> src/expr.rs:10:10 | 10 | pub enum Expression { | ^^^^^^^^^^ note: required by an implicit `Sized` bound in `std::option::Option` --> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:572:1 ...and many, many similar errors ``` It compiles successfully on Rust >=1.79, so this commit can be reverted once our MSRV reaches it.
Configuration menu - View commit details
-
Copy full SHA for a1c6392 - Browse repository at this point
Copy the full SHA a1c6392View commit details
Commits on Nov 26, 2024
-
feat!: replace Cow<'static, _> with 'a
This adds a bunch of lifetimes, but it works with `.into()` when a borrowed value's array container is stored in another place, without the need of `Cow::Borrowed`: ``` let objects = [ NfObject::ListObject(NfListObject::Table(Table { family: NfFamily::INet, name: "some_inet_table".into(), // here handle: None, })), // ... ]; let expected = Nftables { objects: objects.into(); // and here }; ``` However, `Cow::{Borrowed, Owned}` still needs to be used when you want to write the above in one statement.
Configuration menu - View commit details
-
Copy full SHA for f037160 - Browse repository at this point
Copy the full SHA f037160View commit details -
Configuration menu - View commit details
-
Copy full SHA for dece884 - Browse repository at this point
Copy the full SHA dece884View commit details