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

🐎 use rayon global thread #1307

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cli/src/command/append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ fn append_to_archive(args: AppendCommand) -> io::Result<()> {
.open(archive_path.with_part(num).unwrap())?;
archive = archive.read_next_archive(file)?;
};
let pool = utils::thread::build()?;

let mut files = args.file.files;
if args.files_from_stdin {
Expand Down Expand Up @@ -172,7 +171,7 @@ fn append_to_archive(args: AppendCommand) -> io::Result<()> {
};
for file in target_items {
let tx = tx.clone();
pool.scope_fifo(|s| {
rayon::scope_fifo(|s| {
s.spawn_fifo(|_| {
log::debug!("Adding: {}", file.display());
tx.send(create_entry(&file, create_options.clone()))
Expand Down
8 changes: 2 additions & 6 deletions cli/src/command/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ where
W: Write,
F: FnMut() -> io::Result<W>,
{
let pool = utils::thread::build()?;

let (tx, rx) = std::sync::mpsc::channel();
let option = if solid {
WriteOptions::store()
Expand All @@ -223,7 +221,7 @@ where
};
for file in target_items {
let tx = tx.clone();
pool.scope_fifo(|s| {
rayon::scope_fifo(|s| {
s.spawn_fifo(|_| {
log::debug!("Adding: {}", file.display());
tx.send(create_entry(&file, create_options.clone()))
Expand Down Expand Up @@ -260,8 +258,6 @@ fn create_archive_with_split(
target_items: Vec<PathBuf>,
max_file_size: usize,
) -> io::Result<()> {
let pool = utils::thread::build()?;

let (tx, rx) = std::sync::mpsc::channel();
let option = if solid {
WriteOptions::store()
Expand All @@ -275,7 +271,7 @@ fn create_archive_with_split(
};
for file in target_items {
let tx = tx.clone();
pool.scope_fifo(|s| {
rayon::scope_fifo(|s| {
s.spawn_fifo(|_| {
log::debug!("Adding: {}", file.display());
tx.send(create_entry(&file, create_options.clone()))
Expand Down
8 changes: 2 additions & 6 deletions cli/src/command/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ where
let globs =
GlobPatterns::new(files).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;

let pool = utils::thread::build()?;

let mut hard_link_entries = Vec::new();

let (tx, rx) = std::sync::mpsc::channel();
Expand All @@ -163,7 +161,7 @@ where
return Ok(());
}
let tx = tx.clone();
pool.scope_fifo(|s| {
rayon::scope_fifo(|s| {
s.spawn_fifo(|_| {
tx.send(extract_entry(item, password, &args))
.unwrap_or_else(|e| panic!("{e}: {}", item_path));
Expand Down Expand Up @@ -196,8 +194,6 @@ where
let globs =
GlobPatterns::new(files).map_err(|e| io::Error::new(io::ErrorKind::InvalidInput, e))?;

let pool = utils::thread::build()?;

let mut hard_link_entries = Vec::<NormalEntry>::new();

let (tx, rx) = std::sync::mpsc::channel();
Expand All @@ -213,7 +209,7 @@ where
return Ok(());
}
let tx = tx.clone();
pool.scope_fifo(|s| {
rayon::scope_fifo(|s| {
s.spawn_fifo(|_| {
tx.send(extract_entry(item, password, &args))
.unwrap_or_else(|e| panic!("{e}: {}", item_path));
Expand Down
6 changes: 2 additions & 4 deletions cli/src/command/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ fn update_archive<Strategy: TransformStrategy>(args: UpdateCommand) -> io::Resul
None,
)?;

let pool = utils::thread::build()?;

let (tx, rx) = std::sync::mpsc::channel();

let random = rand::random::<usize>();
Expand Down Expand Up @@ -253,7 +251,7 @@ fn update_archive<Strategy: TransformStrategy>(args: UpdateCommand) -> io::Resul
&& need_update_condition(&normalized_path, entry.metadata()).unwrap_or(true)
{
let tx = tx.clone();
pool.scope_fifo(|s| {
rayon::scope_fifo(|s| {
s.spawn_fifo(|_| {
log::debug!("Updating: {}", file.display());
tx.send(create_entry(&file, create_options.clone()))
Expand All @@ -274,7 +272,7 @@ fn update_archive<Strategy: TransformStrategy>(args: UpdateCommand) -> io::Resul
// NOTE: Add new entries
for file in target_items {
let tx = tx.clone();
pool.scope_fifo(|s| {
rayon::scope_fifo(|s| {
s.spawn_fifo(|_| {
log::debug!("Adding: {}", file.display());
tx.send(create_entry(&file, create_options.clone()))
Expand Down
1 change: 0 additions & 1 deletion cli/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ pub(crate) mod mmap;
pub(crate) mod os;
mod path;
pub(crate) mod str;
pub(crate) mod thread;

pub(crate) use {globs::*, path::*};
12 changes: 0 additions & 12 deletions cli/src/utils/thread.rs

This file was deleted.

Loading