on master help sign in
syntax: Drop the rayon dependency for threadpool.

We just need a small concurrent threadpool for compilation.

commitc6456d04b9f16ed8f5ad0f256a38218b514de5dc authorBlaž Hrastnik <blaz@mxxn.io> dateWed 24 Feb 2021, 13:13 (6 years ago) parent41c0d58
3 files changed+32−88
Cargo.lock+10−82 helix-syntax/Cargo.toml+1−1 helix-syntax/build.rs+21−5
Cargo.lock+10−82
@@ -226,47 +226,6 @@ dependencies = [
226226 "cache-padded",
227227]
228228
229−[[package]]
230−name = "const_fn"
231−version = "0.4.5"
232−source = "registry+https://github.com/rust-lang/crates.io-index"
233−checksum = "28b9d6de7f49e22cf97ad17fc4036ece69300032f45f78f30b4a4482cdc3f4a6"
234−
235−[[package]]
236−name = "crossbeam-channel"
237−version = "0.5.0"
238−source = "registry+https://github.com/rust-lang/crates.io-index"
239−checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
240−dependencies = [
241− "cfg-if 1.0.0",
242− "crossbeam-utils",
243−]
244−
245−[[package]]
246−name = "crossbeam-deque"
247−version = "0.8.0"
248−source = "registry+https://github.com/rust-lang/crates.io-index"
249−checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9"
250−dependencies = [
251− "cfg-if 1.0.0",
252− "crossbeam-epoch",
253− "crossbeam-utils",
254−]
255−
256−[[package]]
257−name = "crossbeam-epoch"
258−version = "0.9.1"
259−source = "registry+https://github.com/rust-lang/crates.io-index"
260−checksum = "a1aaa739f95311c2c7887a76863f500026092fb1dce0161dab577e559ef3569d"
261−dependencies = [
262− "cfg-if 1.0.0",
263− "const_fn",
264− "crossbeam-utils",
265− "lazy_static",
266− "memoffset",
267− "scopeguard",
268−]
269−
270229[[package]]
271230name = "crossbeam-utils"
272231version = "0.8.1"
@@ -325,12 +284,6 @@ dependencies = [
325284 "winapi",
326285]
327286
328−[[package]]
329−name = "either"
330−version = "1.6.1"
331−source = "registry+https://github.com/rust-lang/crates.io-index"
332−checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
333−
334287[[package]]
335288name = "event-listener"
336289version = "2.5.1"
@@ -579,7 +532,7 @@ name = "helix-syntax"
579532version = "0.1.0"
580533dependencies = [
581534 "cc",
582− "rayon",
535+ "threadpool",
583536 "tree-sitter",
584537]
585538
@@ -769,15 +722,6 @@ version = "2.3.4"
769722source = "registry+https://github.com/rust-lang/crates.io-index"
770723checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
771724
772−[[package]]
773−name = "memoffset"
774−version = "0.6.1"
775−source = "registry+https://github.com/rust-lang/crates.io-index"
776−checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87"
777−dependencies = [
778− "autocfg",
779−]
780−
781725[[package]]
782726name = "mio"
783727version = "0.7.8"
@@ -971,31 +915,6 @@ dependencies = [
971915 "proc-macro2",
972916]
973917
974−[[package]]
975−name = "rayon"
976−version = "1.5.0"
977−source = "registry+https://github.com/rust-lang/crates.io-index"
978−checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674"
979−dependencies = [
980− "autocfg",
981− "crossbeam-deque",
982− "either",
983− "rayon-core",
984−]
985−
986−[[package]]
987−name = "rayon-core"
988−version = "1.9.0"
989−source = "registry+https://github.com/rust-lang/crates.io-index"
990−checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a"
991−dependencies = [
992− "crossbeam-channel",
993− "crossbeam-deque",
994− "crossbeam-utils",
995− "lazy_static",
996− "num_cpus",
997−]
998−
999918[[package]]
1000919name = "redox_syscall"
1001920version = "0.2.5"
@@ -1264,6 +1183,15 @@ dependencies = [
12641183 "once_cell",
12651184]
12661185
1186+[[package]]
1187+name = "threadpool"
1188+version = "1.8.1"
1189+source = "registry+https://github.com/rust-lang/crates.io-index"
1190+checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
1191+dependencies = [
1192+ "num_cpus",
1193+]
1194+
12671195[[package]]
12681196name = "tinyvec"
12691197version = "1.1.1"
helix-syntax/Cargo.toml+1−1
@@ -11,4 +11,4 @@ tree-sitter = "0.17"
1111
1212[build-dependencies]
1313cc = { version = "1", features = ["parallel"] }
14−rayon = { version = "1.5" }
14+threadpool = { version = "1.0" }
helix-syntax/build.rs+21−5
@@ -1,7 +1,8 @@
1−use rayon::prelude::*;
21use std::path::PathBuf;
32use std::{env, fs};
43
4+use std::sync::mpsc::channel;
5+
56fn get_opt_level() -> u32 {
67 env::var("OPT_LEVEL").unwrap().parse::<u32>().unwrap()
78}
@@ -115,10 +116,25 @@ fn main() {
115116 "tree-sitter-cpp".to_string(),
116117 ];
117118 let dirs = collect_tree_sitter_dirs(ignore);
118− dirs.par_iter().for_each(|dir| {
119− let language = &dir[12..]; // skip tree-sitter- prefix
120− build_dir(&dir, &language);
121− });
119+
120+ let mut n_jobs = 0;
121+ let pool = threadpool::Builder::new().build(); // by going through the builder, it'll use num_cpus
122+ let (tx, rx) = channel();
123+
124+ for dir in dirs {
125+ let tx = tx.clone();
126+ n_jobs += 1;
127+
128+ pool.execute(move || {
129+ let language = &dir[12..]; // skip tree-sitter- prefix
130+ build_dir(&dir, &language);
131+
132+ // report progress
133+ tx.send(1).unwrap();
134+ });
135+ }
136+ assert_eq!(rx.iter().take(n_jobs).fold(0, |a, b| a + b), n_jobs);
137+
122138 build_dir("tree-sitter-typescript/tsx", "tsx");
123139 build_dir("tree-sitter-typescript/typescript", "typescript");
124140}