Repository navigation
options: add --nice process-priority controls #1011
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
Open
michaelmess-de
wants to merge
24
commits into
RsyncProject:master
Choose a base branch
from
michaelmess-de:niceness-nice-level-improved
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,702
−6
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a44ff28
niceness: change nice and ionice level of the local and/or remote pro…
michaelmess-de 15286d6
Skip tests to check if build succeeds
michaelmess-de e83de81
Added new combined test (incomplete) and skip tests with new helper f…
michaelmess-de 3a2bb40
Use skip method to skip tests
michaelmess-de ba189a7
Added combined strace test
michaelmess-de 919577b
Added test case
michaelmess-de 4f49ce4
Added test cases
michaelmess-de ecda7b5
Deleted local + remote test (we have a combined one now)
michaelmess-de b046534
Improved skip text message
michaelmess-de 27f2894
Removed platform skip
michaelmess-de e187183
Added cygwin and macos to skip list
michaelmess-de 80094f0
Skip on solaris
michaelmess-de e84dc47
Corrected Solaris skip
michaelmess-de 249b257
Install strace on almalinux
michaelmess-de f07325a
Corrected Solaris skip
michaelmess-de d60594a
Added kernel-headers and glibc-devel package
michaelmess-de 7de42fb
Corrected rsync call
michaelmess-de 4105bf9
Also check for the result with root permissions
michaelmess-de 28f700d
Corrected fail message
michaelmess-de 9fa733e
Corrected split(...)
michaelmess-de 2fc9d8d
Corrected split(...)
michaelmess-de f947161
Corrected split(...)
michaelmess-de cea50b6
Corrected split(...)
michaelmess-de 4260e4b
Corrected missing import
michaelmess-de File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * Renice or ionice the rsync process to reduce its impact on the system | ||
| * ionice_string.c - string conversion utilities for ionice | ||
| * | ||
| * Copyright (C) 2026 Michael Mess | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along | ||
| * with this program; if not, visit the http://fsf.org website. | ||
| */ | ||
|
|
||
| #include <strings.h> | ||
| #include "niceness.h" | ||
|
|
||
| /* | ||
| * Get the string representation for the given ionice_value | ||
| */ | ||
| const char *intToIoniceValueString(int ionice_value) | ||
| { | ||
| if (ionice_value<-8) return 0; | ||
| if (ionice_value>9) return 0; | ||
| return Ionice_ValueStrings[ionice_value+8]; | ||
| } | ||
|
|
||
| /* | ||
| * Parse string into ionice_value. Returns 1 on success, 0 otherwise. | ||
| */ | ||
| int ioniceStringToInt(char * string, int *ionice_value) | ||
| { | ||
| for (int i=0; Ionice_ValueStrings[i]; i++) | ||
| { | ||
| if (strncasecmp(string, Ionice_ValueStrings[i], 4) == 0) // All values are 4 chars long | ||
| { | ||
| *ionice_value=i-8; | ||
| return 1; | ||
| } | ||
| } | ||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Renice or ionice the rsync process to reduce its impact on the system | ||
| * ionice_string.h - string conversion utilities for ionice | ||
| * | ||
| * Copyright (C) 2026 Michael Mess | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along | ||
| * with this program; if not, visit the http://fsf.org website. | ||
| */ | ||
|
|
||
| #include "niceness.h" | ||
|
|
||
| /* | ||
| * Get the string representation for the given ionice_value | ||
| */ | ||
| const char *intToIoniceValueString(int ionice_value); | ||
|
|
||
| /* | ||
| * Parse string into ionice_value. Returns 1 on success, 0 otherwise. | ||
| */ | ||
| int ioniceStringToInt(char * string, int *ionice_value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /* | ||
| * Renice or ionice the rsync process to reduce its impact on the system | ||
| * niceness.c - core niceness state holder | ||
| * | ||
| * Copyright (C) 2026 Michael Mess | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along | ||
| * with this program; if not, visit the http://fsf.org website. | ||
| */ | ||
|
|
||
| #include "niceness.h" | ||
|
|
||
| /* | ||
| * String representation of ionice. All strings have to be 4 characters long. | ||
| */ | ||
| const char *Ionice_ValueStrings[] = { | ||
| "rt_0", | ||
| "rt_1", | ||
| "rt_2", | ||
| "rt_3", | ||
| "rt_4", | ||
| "rt_5", | ||
| "rt_6", | ||
| "rt_7", | ||
| "none", | ||
| "be_0", | ||
| "be_1", | ||
| "be_2", | ||
| "be_3", | ||
| "be_4", | ||
| "be_5", | ||
| "be_6", | ||
| "be_7", | ||
| "idle", | ||
| 0 | ||
| }; | ||
|
|
||
| struct niceness niceness = { | ||
| /* If set to other than 0, be nice on the local or remote site | ||
| * Contains the nice priority to be set on the process, or 0=feature is turned off, no priority will be set. | ||
| * I have to admit, that it is not possible to set a nice value of 0 with this code, | ||
| * but in most cases 0 should be the priority of the newly started rsync process already anyway. | ||
| */ | ||
| .nice_local = 0, | ||
| .nice_remote = 0, | ||
|
|
||
| /* If set to other than 0, be ionice on the local or remote site | ||
| * Currently only idle is supported for ionice when turned on. | ||
| */ | ||
| .ionice_local = 0, | ||
| .ionice_remote = 0, | ||
| }; | ||
|
|
||
| /** | ||
| * Turn niceness off (no nice and no ionice) | ||
| */ | ||
| void niceness_turn_off() | ||
| { | ||
| niceness.nice_local = 0; | ||
| niceness.nice_remote = 0; | ||
| niceness.ionice_local = 0; | ||
| niceness.ionice_remote = 0; | ||
| } | ||
|
|
||
| /** | ||
| * Turn niceness on (nice and ionice set to default values for maximum niceness) | ||
| */ | ||
| void niceness_turn_on() | ||
| { | ||
| niceness.nice_local = NICENESS_RENICE_DEFAULT_PRIO; | ||
| niceness.nice_remote = NICENESS_RENICE_DEFAULT_PRIO; | ||
| niceness.ionice_local = NICENESS_IONICE_DEFAULT_PRIO; | ||
| niceness.ionice_remote = NICENESS_IONICE_DEFAULT_PRIO; | ||
| } | ||
|
|
||
| /** | ||
| * Apply nice/ionice local to this rsync process | ||
| */ | ||
| void niceness_renice_and_ionice_me() | ||
| { | ||
| if (niceness.nice_local) { | ||
| niceness_renice_me(niceness.nice_local); | ||
| } | ||
|
|
||
| if (niceness.ionice_local) { | ||
| niceness_ionice_me(niceness.ionice_local); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| /* | ||
| * Renice or ionice the rsync process to reduce its impact on the system | ||
| * | ||
| * Copyright (C) 2026 Michael Mess | ||
| * | ||
| * This program is free software; you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation; either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License along | ||
| * with this program; if not, visit the http://fsf.org website. | ||
| */ | ||
|
|
||
| #ifndef NICENESS_H // Ensure that this header file is never included more than once, thus avoiding errors with duplicate definitions | ||
| #define NICENESS_H 1 | ||
|
|
||
| /* | ||
| * Enum for ionice values. | ||
| * Constants with negative numbers need root permission, others can be set by any user. | ||
| * RT_X is realtime priority | ||
| * BE_X is best effort with the given level | ||
| * IDLE means the process gets served only when no other processes are using disk io. | ||
| * NONE means best effort with level calculated by the formula (cpu_nice + 20) / 5 | ||
| * and is the default that does not need to be set. | ||
| */ | ||
| enum Ionice_Values { | ||
| RT_0 =-8, | ||
| RT_1 =-7, | ||
| RT_2 =-6, | ||
| RT_3 =-5, | ||
| RT_4 =-4, | ||
| RT_5 =-3, | ||
| RT_6 =-2, | ||
| RT_7 =-1, | ||
| NONE = 0, | ||
| BE_0 = 1, | ||
| BE_1 = 2, | ||
| BE_2 = 3, | ||
| BE_3 = 4, | ||
| BE_4 = 5, | ||
| BE_5 = 6, | ||
| BE_6 = 7, | ||
| BE_7 = 8, | ||
| IDLE = 9 | ||
| }; | ||
|
|
||
| /* | ||
| * String representation of ionice. All strings have to be 4 characters long. | ||
| */ | ||
| extern const char *Ionice_ValueStrings[]; | ||
| /* | ||
| const char *Ionice_ValueStrings[] = { | ||
| "rt_0", | ||
| "rt_1", | ||
| "rt_2", | ||
| "rt_3", | ||
| "rt_4", | ||
| "rt_5", | ||
| "rt_6", | ||
| "rt_7", | ||
| "none", | ||
| "be_0", | ||
| "be_1", | ||
| "be_2", | ||
| "be_3", | ||
| "be_4", | ||
| "be_5", | ||
| "be_6", | ||
| "be_7", | ||
| "idle", | ||
| 0 | ||
| }; | ||
| */ | ||
|
|
||
| /* | ||
| * Constants to be used when no specific argument is given | ||
| */ | ||
| #define NICENESS_RENICE_DEFAULT_PRIO 19; | ||
| #define NICENESS_IONICE_DEFAULT_PRIO IDLE; | ||
|
|
||
| /* | ||
| * Struct to hold state for niceness | ||
| */ | ||
| struct niceness { | ||
| /* If set to other than 0, be nice on the local or remote site | ||
| * Contains the nice priority to be set on the process, or 0=feature is turned off, no priority will be set. | ||
| * I have to admit, that it is not possible to set a nice value of 0 with this code, | ||
| * but in most cases 0 should be the priority of the newly started rsync process already anyway. | ||
| */ | ||
| int nice_local; | ||
| int nice_remote; | ||
|
|
||
| /* If set to other than 0, be ionice on the local or remote site | ||
| * Currently only idle is supported for ionice when turned on. | ||
| */ | ||
| int ionice_local; | ||
| int ionice_remote; | ||
| }; | ||
|
|
||
| extern struct niceness niceness; | ||
|
|
||
|
|
||
| /* | ||
| * Some methods to simply turn niceness on or off or configure with an argument | ||
| */ | ||
| void niceness_turn_off(); | ||
| void niceness_turn_on(); | ||
| int niceness_parse_argument(const char * arg); | ||
| int niceness_local_wants_elevated_priorities(); | ||
|
|
||
| /* | ||
| * Apply nice and ionice on this local process | ||
| */ | ||
| void niceness_renice_and_ionice_me(); | ||
| void niceness_renice_me(int prio); | ||
| void niceness_ionice_me(int ionice_value); | ||
|
|
||
| /* | ||
| * Utility function to get the string representation of an ionice value | ||
| */ | ||
| const char *intToIoniceValueString(int ionice_value); | ||
|
|
||
| #endif // ifndef NICENESS_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.