rust-cli / rust-cli/config-rs

To much String::clone()?

Open
#240 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-enhancement E-help-wanted
Dominant language
Rust
Stars
3.2k
Forks
265
Avg merge
2h 42m
Merged PRs (30d)
4

Description

In src/value.rs (https://github.com/mehcode/config-rs/blob/master/src/value.rs#L148) we clone() a String. That leads to a lot of String cloning when using this library.

Yesterday, I played around with cargo-flamegraph and cargo-bench a bit because of this. I am by no means an expert on how to do performance analysis and these kind of things, but from what I could see, String::clone() is not insignificant in the runtime cost of this crate.
Maybe, and I want to empathize this, maybe we could gain a lot from removing this one clone() call.

BUT the problem is, that it is not simple! I tried a bit, and using a &'a str in this place would basically put a lifetime on everything in the crate.
In some places, it is not even possible to have a lifetime... maybe I should have invested more time to gain some results,... I am not sure.

Maybe someone else has an idea, or is better with driving such analysis...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/value.rs around line 148 and inspect how the cloned String flows through the crate. Use cargo-flamegraph and cargo-bench to measure whether this clone is a significant cost, then assess the lifetime implications of changing it. Done means having benchmark evidence and a tested, maintainable approach to reducing or retaining the clone.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.