Replace pipe by ringtail to improve stdin read performances

This commit is contained in:
Clément Renault 2020-08-21 16:08:32 +02:00
parent ada30c2789
commit ff479c865d
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
3 changed files with 12 additions and 23 deletions

View file

@ -73,7 +73,9 @@ struct Opt {
verbose: usize,
/// CSV file to index, if unspecified the CSV is read from standard input.
/// Note that it is much faster to index from a file.
///
/// Note that it is much faster to index from a file as when the indexer reads from stdin
/// it will dedicate a thread for that and context switches could slow down the indexing jobs.
csv_file: Option<PathBuf>,
}
@ -507,7 +509,7 @@ fn main() -> anyhow::Result<()> {
None => {
let mut csv_readers = Vec::new();
let mut writers = Vec::new();
for (r, w) in (0..num_threads).map(|_| pipe::pipe()) {
for (r, w) in (0..num_threads).map(|_| ringtail::io::pipe()) {
let r = Box::new(r) as Box<dyn Read + Send>;
csv_readers.push(csv::Reader::from_reader(r));
writers.push(w);