make threads floats
This commit is contained in:
parent
1c0a87e9d8
commit
add254d996
3 changed files with 18 additions and 16 deletions
|
@ -16,7 +16,7 @@ Note: This primarily uses LibreWolf and Fedora as examples of packages and distr
|
|||
|
||||
- `log-level` (integer): Log level `0`-`3` (error, warning, info, or debug)
|
||||
- Default: 1 - warning
|
||||
- `max-threads` (integer): The maximum number of threads to be used
|
||||
- `max-threads` (float): The maximum number of threads to be used
|
||||
- **See also**: [`threads`](#job-config)
|
||||
- Default is CPU's threads - 2
|
||||
- `max-jobs` (integer): The maximum number of jobs to be run at once
|
||||
|
@ -26,7 +26,7 @@ Note: This primarily uses LibreWolf and Fedora as examples of packages and distr
|
|||
|
||||
**Multithreading notes (IMPORTANT)**: Gregory will first run compilation jobs, then packaging jobs for whatever programs are done, then run the `update-repo` for whichever distros are finished. For this reason, the distro names listed under `packaging` and `update-repo` *must* match.
|
||||
|
||||
**Multithreading/multiple jobs is not implemented yet**
|
||||
**Multithreading is not implemented yet**
|
||||
|
||||
## Job config
|
||||
|
||||
|
@ -35,7 +35,7 @@ Note: This primarily uses LibreWolf and Fedora as examples of packages and distr
|
|||
- If you just want to run stuff, you don't need this, but it's *highly* recommended as it allows you to filter your logs.
|
||||
- `revision` (string): A revision id for the job, such as a version number for a compilation script
|
||||
- Default is `1`
|
||||
- `threads` (integer): The maximum number of vCPUs/threads to dedicate to a job; this can be a fractional number
|
||||
- `threads` (float): The maximum number of vCPUs/threads to dedicate to a job; this can be a fractional number
|
||||
- Set this as less than or equal to the max number of threads the thing you're running will use
|
||||
- See `--cpus` in the [`podman run` docs](https://docs.podman.io/en/latest/markdown/podman-run.1.html#cpus)
|
||||
- *Root may be required for this argument*
|
||||
|
@ -48,6 +48,8 @@ Note: This primarily uses LibreWolf and Fedora as examples of packages and distr
|
|||
- `shell` (string): The shell to run the commands in
|
||||
- Default: `/bin/sh`
|
||||
|
||||
Note: `id` and `revision` are *not* for the package version, they are for
|
||||
|
||||
## Packages (`packages`)
|
||||
|
||||
Example:
|
||||
|
|
24
src/data.rs
24
src/data.rs
|
@ -22,7 +22,7 @@ pub(crate) struct Config {
|
|||
pub(crate) max_jobs: u32,
|
||||
/// Maximum number of threads to use
|
||||
#[serde(default = "max_threads", rename = "max-threads")]
|
||||
pub(crate) max_threads: u32,
|
||||
pub(crate) max_threads: f32,
|
||||
#[serde(default = "data", rename = "data-dir")]
|
||||
pub(crate) data_dir: String,
|
||||
/// Holds the packages, including their compilation and packaging
|
||||
|
@ -52,7 +52,7 @@ pub(crate) struct Job {
|
|||
///
|
||||
/// If `threads` isn't specified, it will fall back to `max_threads` (from [`Config`]); the same behavior applies if `threads` is greater than `max_threads`
|
||||
#[serde(default = "job_threads")]
|
||||
pub(crate) threads: u32,
|
||||
pub(crate) threads: f32,
|
||||
/// The OCI image to run it in
|
||||
///
|
||||
/// For example, `docker.io/library/debian:latest`
|
||||
|
@ -123,15 +123,15 @@ pub(crate) fn log_level() -> u8 {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/// Returns the default number of max threads
|
||||
pub(crate) fn max_threads() -> u32 {
|
||||
let total_threads = thread::available_parallelism().unwrap().get() as u32;
|
||||
if total_threads >= 32 {
|
||||
return total_threads - 4;
|
||||
} else if total_threads >= 12 {
|
||||
return total_threads - 2;
|
||||
} else if total_threads >= 3 {
|
||||
return total_threads - 1;
|
||||
/// Returns the default number of max threads.
|
||||
pub(crate) fn max_threads() -> f32 {
|
||||
let total_threads = thread::available_parallelism().unwrap().get() as f32;
|
||||
if total_threads >= 32.0 {
|
||||
return total_threads - 4.0;
|
||||
} else if total_threads >= 12.0 {
|
||||
return total_threads - 2.0;
|
||||
} else if total_threads >= 3.0 {
|
||||
return total_threads - 1.0;
|
||||
} else {
|
||||
return total_threads;
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ pub(crate) fn volumes() -> HashMap<String, String> {
|
|||
}
|
||||
|
||||
/// Returns the default number of threads for a job - [`max_threads()`]
|
||||
pub(crate) fn job_threads() -> u32 {
|
||||
pub(crate) fn job_threads() -> f32 {
|
||||
return max_threads();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ fn run(config_path: String) {
|
|||
|
||||
fn run_job(conf: Config, job: Job) -> JobExitStatus {
|
||||
// limit threads to max_threads in the config
|
||||
let mut threads: u32 = job.threads;
|
||||
let mut threads = job.threads;
|
||||
if job.threads > conf.max_threads {
|
||||
threads = conf.max_threads;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue