Skip to content

[WIP] Rust rewrite + Refactor #465

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

Draft
wants to merge 18 commits into
base: trunk
Choose a base branch
from

Conversation

HeitorAugustoLN
Copy link
Member

@HeitorAugustoLN HeitorAugustoLN commented Feb 26, 2025

Performance benchmarks
❯ time kwriteconfig6 --file kwinrc --group default --key idk a
0.00user 0.00system 0:00.05elapsed 9%CPU (0avgtext+0avgdata 13672maxresident)k
0inputs+208outputs (0major+615minor)pagefaults 0swaps

❯ time result/bin/plasma-manager write --file kwinrc --group sla/akk --key bubu sla
0.00user 0.00system 0:00.00elapsed 100%CPU (0avgtext+0avgdata 2412maxresident)k
0inputs+8outputs (0major+105minor)pagefaults 0swaps
Performance benchmarks (with kconfig-rs)

Creating a new entry

❯ time result/bin/plasma-manager write --file kwinrc --group sla/akk --key bubu sla

Executed in    2.30 millis    fish           external
 usr time    0.09 millis    0.09 millis    0.00 millis
 sys time    2.27 millis    1.02 millis    1.25 millis

❯ time kwriteconfig6 --file kwinrc --group default --key idk a

Executed in  109.40 millis    fish           external
 usr time    7.77 millis  288.00 micros    7.48 millis
 sys time   18.02 millis  843.00 micros   17.18 millis

You can start trying the new command-line interface by building it with:
nix build github:HeitorAugustoLN/plasma-manager/rust-rewrite#plasma-manager

Add the foundation for a new CLI tool written in Rust as an efficient
alternative to KDE configuration tools. This initial implementation includes:

- Basic command structure with the first 'write' subcommand
- Support for writing key-value pairs to config files
- XDG directory handling with support for nested groups
- Configuration file parsing and modification

Performance benchmarks for the 'write' command:
- plasma-manager: 0.00s elapsed, 2.4MB memory, 105 page faults, 8 outputs
- kwriteconfig6: 0.05s elapsed, 13.4MB memory, 615 page faults, 208 outputs

This first implementation achieves a ~5x speed improvement while using ~80% less
memory compared to the default KDE tool. More commands will be added in future
commits.
This commit adds a custom fork of the rust-ini library (kconfig-rs) that supports
the nested section format used by KDE configuration files (e.g., [Section][Subsection]).
It changes the section type from String to Vec<String> and updates the parser and
writer accordingly. The implementation properly handles the KDE configuration format
with nested sections while maintaining compatibility with standard INI files.
- Improve performance by using pre-allocated capacity in String creation
- Fix Clippy warnings about inefficient string building from iterators
- Replace format!().collect() pattern with direct string manipulation
- Maintain identical functionality while reducing memory allocations
@HeitorAugustoLN
Copy link
Member Author

Implemented rc2nix in the plasma-manager CLI, with some improvements such as not escape quoting every key and also not collapsing every configuration. So it now returns a cleaner output.

@HeitorAugustoLN
Copy link
Member Author

It also supports keys without groups, fixing #17. Though this still needs to be implemented in the modules to work correctly

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.

1 participant