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

nixos/restic: add option maxCpuCores to limit cpu-usage per backup-job #314668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SebTM
Copy link
Contributor

@SebTM SebTM commented May 25, 2024

Description of changes

nixos/restic: add option maxCpuCores to limit cpu-usage per backup-job

Uses go environment-variable "GOMAXPROCS" as suggested in the manual.
https://restic.readthedocs.io/en/latest/047_tuning_backup_parameters.html#cpu-usage

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels May 25, 2024
@SebTM SebTM changed the title nixos/restic: replace 'with lib;', add option maxCpuCores to limit cpu-usage per backup-job, reformat nixfmt-rfc-style nixos/restic: add option maxCpuCores to limit cpu-usage per backup-job, refactorings May 25, 2024
@SebTM SebTM requested review from ajs124, mbrgm and dotlambda May 25, 2024 20:05
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels May 25, 2024
Copy link
Member

@dotlambda dotlambda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for this option. Just use rcloneConfig.GOMAXPROCS.

@SebTM
Copy link
Contributor Author

SebTM commented May 26, 2024

Thanks for the feedback, I see that this will work - but it's not very intuitive/good UX especially for new users. What about renaming rcloneConfig to environment or Config and keeping infos to specify backend e.g. rcloneConfig or GOMAXPROCS there to limit max cpu cores?

I also tried searching for the environment-variable with language-nix through github (user-configs, https://github.com/search?q=GOMAXPROCS+language%3ANix&type=code) so it might not be popular or do I have another issue if my fan goes crazy while restic is running?

@dotlambda
Copy link
Member

What about renaming rcloneConfig to environment

That's probably a good idea. But I'm not sure it's worth a breaking change.

You could add GOMAXPROCS to the example.

@SebTM
Copy link
Contributor Author

SebTM commented May 26, 2024

Had another look - we can't use rcloneConfig here - as it uses rcloneAttrToConf:

rcloneAttrToConf = v: "RCLONE_CONFIG_" + toUpper (rcloneRemoteName + "_" + v);

which prefixes the environment-variables - so maybe it's still the best option or add customEnvironement option?

I know that I could do systemd.services."restic-backups-${name}".environment but that's more a hack for me.

@SebTM SebTM requested a review from dotlambda June 20, 2024 21:24
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/1016/147

@SebTM
Copy link
Contributor Author

SebTM commented Jul 12, 2024

@dotlambda ping?

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/1016/161

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/4265

@SebTM
Copy link
Contributor Author

SebTM commented Aug 14, 2024

Did my best to get feedback/review - will rebase-merge after next week 21/08/2024 - if nobody complains/raises concerns.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/4540

@SebTM SebTM requested review from dotlambda and removed request for ajs124, mbrgm and dotlambda September 10, 2024 20:16
@SebTM SebTM changed the title nixos/restic: add option maxCpuCores to limit cpu-usage per backup-job, refactorings nixos/restic: add option maxCpuCores to limit cpu-usage per backup-job Sep 10, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2024
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants