Commit 6ad3a4c0 authored by SamwiseFilmore's avatar SamwiseFilmore

WIP: Add rayon par_iter; add/remove trace!() calls

Note that this commit ends up with a page fault, which I've traced to
line 127 of service_tree.rs. I'm adding this commit so @jackpot51 can give
me a hand.
parent f109eac8
Pipeline #2725 passed with stage
in 2 minutes and 35 seconds
[[package]]
name = "arrayvec"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "0.1.2" version = "0.1.2"
...@@ -59,6 +67,42 @@ dependencies = [ ...@@ -59,6 +67,42 @@ dependencies = [
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "crossbeam-deque"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-epoch"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-utils"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "either"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "failure" name = "failure"
version = "0.1.5" version = "0.1.5"
...@@ -109,6 +153,7 @@ dependencies = [ ...@@ -109,6 +153,7 @@ dependencies = [
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"generational-arena 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "generational-arena 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)",
...@@ -116,6 +161,11 @@ dependencies = [ ...@@ -116,6 +161,11 @@ dependencies = [
"toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "lazy_static"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.48" version = "0.2.48"
...@@ -129,6 +179,16 @@ dependencies = [ ...@@ -129,6 +179,16 @@ dependencies = [
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "memoffset"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "nodrop"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.39" version = "0.1.39"
...@@ -142,6 +202,14 @@ name = "num-traits" ...@@ -142,6 +202,14 @@ name = "num-traits"
version = "0.2.6" version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "num_cpus"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "owning_ref" name = "owning_ref"
version = "0.3.3" version = "0.3.3"
...@@ -203,6 +271,27 @@ name = "rand_core" ...@@ -203,6 +271,27 @@ name = "rand_core"
version = "0.3.0" version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rayon"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rayon-core"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "rdrand" name = "rdrand"
version = "0.4.0" version = "0.4.0"
...@@ -221,6 +310,11 @@ name = "rustc-demangle" ...@@ -221,6 +310,11 @@ name = "rustc-demangle"
version = "0.1.13" version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.85" version = "1.0.85"
...@@ -335,6 +429,7 @@ version = "0.4.0" ...@@ -335,6 +429,7 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata] [metadata]
"checksum arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "92c7fb76bc8826a8b33b4ee5bb07a247a81e76764ab4d55e8f73e3a4d8808c71"
"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" "checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799"
"checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5" "checksum backtrace 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b5b493b66e03090ebc4343eb02f94ff944e0cbc9ac6571491d170ba026741eb5"
"checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6" "checksum backtrace-sys 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "797c830ac25ccc92a7f8a7b9862bde440715531514594a6154e3d4a54dd769b6"
...@@ -343,15 +438,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -343,15 +438,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum chashmap 2.2.1 (git+https://gitlab.redox-os.org/redox-os/tfs)" = "<none>" "checksum chashmap 2.2.1 (git+https://gitlab.redox-os.org/redox-os/tfs)" = "<none>"
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum generational-arena 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e21bdad35146e7292a8462f37e6c6eafe26e1401737f4ff95b60e2a9afc4f9d5" "checksum generational-arena 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e21bdad35146e7292a8462f37e6c6eafe26e1401737f4ff95b60e2a9afc4f9d5"
"checksum lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a374c89b9db55895453a74c1e38861d9deec0b01b405a82516e9d5de4820dea1"
"checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047" "checksum libc 0.2.48 (registry+https://github.com/rust-lang/crates.io-index)" = "e962c7641008ac010fa60a7dfdc1712449f29c44ef2d4702394aea943ee75047"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" "checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea" "checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1" "checksum num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3a5d7cc97d6d30d8b9bc8fa19bf45349ffe46241e8816f50f62f6d6aaabee1"
"checksum num_cpus 1.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5a69d464bdc213aaaff628444e99578ede64e9c854025aa43b9796530afa9238"
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
"checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e" "checksum parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "149d8f5b97f3c1133e3cfcd8886449959e856b557ff281e292b733d7c69e005e"
"checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa" "checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa"
...@@ -359,9 +462,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" ...@@ -359,9 +462,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" "checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1"
"checksum rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dee497e66d8d76bf08ce20c8d36e16f93749ab0bf89975b4f8ae5cee660c2da2" "checksum rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dee497e66d8d76bf08ce20c8d36e16f93749ab0bf89975b4f8ae5cee660c2da2"
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" "checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
"checksum rayon 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "373814f27745b2686b350dd261bfd24576a6fb0e2c5919b3a2b6005f820b0473"
"checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85"
"checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752" "checksum serde 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "534b8b91a95e0f71bca3ed5824752d558da048d4248c91af873b63bd60519752"
"checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4" "checksum serde_derive 1.0.85 (registry+https://github.com/rust-lang/crates.io-index)" = "a915306b0f1ac5607797697148c223bedeaa36bcc2e28a01441cd638cc6567b4"
"checksum simple_logger 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25111f1d77db1ac3ee11b62ba4b7a162e6bb3be43e28273f0d3935cc8d3ff7fb" "checksum simple_logger 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "25111f1d77db1ac3ee11b62ba4b7a162e6bb3be43e28273f0d3935cc8d3ff7fb"
......
...@@ -9,7 +9,7 @@ chashmap = { git = "https://gitlab.redox-os.org/redox-os/tfs" } ...@@ -9,7 +9,7 @@ chashmap = { git = "https://gitlab.redox-os.org/redox-os/tfs" }
failure = "0.1" failure = "0.1"
generational-arena = "0.2" generational-arena = "0.2"
log = "0.4" log = "0.4"
#rayon = "1.0" rayon = "1.0"
redox_syscall = "0.1" redox_syscall = "0.1"
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"
......
...@@ -11,7 +11,7 @@ use std::io::{Error, Result}; ...@@ -11,7 +11,7 @@ use std::io::{Error, Result};
use std::os::unix::io::{AsRawFd, FromRawFd}; use std::os::unix::io::{AsRawFd, FromRawFd};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use log::{error, trace}; use log::error;
use syscall::flag::{O_RDONLY, O_WRONLY}; use syscall::flag::{O_RDONLY, O_WRONLY};
use crate::service::Service; use crate::service::Service;
...@@ -54,34 +54,25 @@ impl PathExt for Path { ...@@ -54,34 +54,25 @@ impl PathExt for Path {
} }
pub fn main() { pub fn main() {
trace!("initializing logger");
simple_logger::init() simple_logger::init()
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
println!("init: failed to start logger: {}", err); println!("init: failed to start logger: {}", err);
}); });
// This way we can continue to support old systems that still have init.rc // This way we can continue to support old systems that still have init.rc
trace!("testing init type");
if let Ok(_) = fs::metadata("initfs:/etc/init.rc") { if let Ok(_) = fs::metadata("initfs:/etc/init.rc") {
if let Err(err) = legacy::run(&Path::new("initfs:/etc/init.rc")) { if let Err(err) = legacy::run(&Path::new("initfs:/etc/init.rc")) {
error!("failed to run initfs:/etc/init.rc: {}", err); error!("failed to run initfs:/etc/init.rc: {}", err);
} }
} else { } else {
//std::env::set_var("RUST_BACKTRACE", "1");
trace!("parsing initfs services");
let initfs_services = Service::from_dir(INITFS_SERVICE_DIR) let initfs_services = Service::from_dir(INITFS_SERVICE_DIR)
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
error!("error parsing service directory '{}': {}", INITFS_SERVICE_DIR, err); error!("error parsing service directory '{}': {}", INITFS_SERVICE_DIR, err);
vec![] vec![]
}); });
trace!("initializing service graph");
let service_graph = ServiceGraph::new(); let service_graph = ServiceGraph::new();
service_graph.push_services(initfs_services); service_graph.push_services(initfs_services);
trace!("starting initfs services");
service_graph.start_services(); service_graph.start_services();
//* //*
......
...@@ -53,8 +53,8 @@ impl Method { ...@@ -53,8 +53,8 @@ impl Method {
let modified_cmd = self.cmd.drain(..) let modified_cmd = self.cmd.drain(..)
.map(|arg| if arg.trim().starts_with('$') { .map(|arg| if arg.trim().starts_with('$') {
let (_, varname) = arg.split_at(1); let (_, varname) = arg.split_at(1);
let val = env::var(varname).unwrap_or(String::new()); let val = env::var(&varname).unwrap_or(String::new());
println!("{:?}", val); trace!("replacing env ${}={}", varname, val);
val val
} else { } else {
arg arg
...@@ -107,6 +107,7 @@ impl Service { ...@@ -107,6 +107,7 @@ impl Service {
/// Parse a service file, no specific requirements for filetype. /// Parse a service file, no specific requirements for filetype.
pub fn from_file(file_path: impl AsRef<Path>) -> Result<Service, Error> { pub fn from_file(file_path: impl AsRef<Path>) -> Result<Service, Error> {
let file_path = file_path.as_ref(); let file_path = file_path.as_ref();
trace!("parsing service file: {:#?}", file_path);
let mut data = String::new(); let mut data = String::new();
File::open(&file_path)? File::open(&file_path)?
...@@ -133,7 +134,7 @@ impl Service { ...@@ -133,7 +134,7 @@ impl Service {
/// Parse all the toml files in a directory as services /// Parse all the toml files in a directory as services
pub fn from_dir(dir: impl AsRef<Path>) -> Result<Vec<Service>, Error> { pub fn from_dir(dir: impl AsRef<Path>) -> Result<Vec<Service>, Error> {
trace!("parsing services from '{:#?}'", dir.as_ref()); trace!("parsing services from {:#?}", dir.as_ref());
let mut services = vec![]; let mut services = vec![];
......
...@@ -5,7 +5,7 @@ use chashmap::CHashMap; ...@@ -5,7 +5,7 @@ use chashmap::CHashMap;
use failure::{err_msg, Error}; use failure::{err_msg, Error};
use generational_arena::Index; use generational_arena::Index;
use log::{error, warn}; use log::{error, warn};
//use rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use crate::dep_graph::DepGraph; use crate::dep_graph::DepGraph;
use crate::service::{Service, ServiceState}; use crate::service::{Service, ServiceState};
...@@ -17,6 +17,8 @@ use crate::service::{Service, ServiceState}; ...@@ -17,6 +17,8 @@ use crate::service::{Service, ServiceState};
pub struct ServiceGraph { pub struct ServiceGraph {
graph: RwLock<DepGraph<Service>>, graph: RwLock<DepGraph<Service>>,
/// Names of services (and provides of services) mapped to the
/// service index that provides that name.
// Must be sorta global so that dependencies across `push_services` // Must be sorta global so that dependencies across `push_services`
// boundaries link up correctly. // boundaries link up correctly.
redirect_map: CHashMap<String, Index>, redirect_map: CHashMap<String, Index>,
...@@ -36,6 +38,7 @@ impl ServiceGraph { ...@@ -36,6 +38,7 @@ impl ServiceGraph {
/// Push some services into the graph, and add their dependency nodes. /// Push some services into the graph, and add their dependency nodes.
/// Note that this does not start any services, only their metadata /// Note that this does not start any services, only their metadata
/// is inserted into the graph. Metadata for services is not manipulated /// is inserted into the graph. Metadata for services is not manipulated
//TODO: Split this into a couple funcs
pub fn push_services(&self, mut services: Vec<Service>) { pub fn push_services(&self, mut services: Vec<Service>) {
let mut graph = self.graph.write() let mut graph = self.graph.write()
.expect("service graph mutex poisoned"); .expect("service graph mutex poisoned");
...@@ -94,6 +97,8 @@ impl ServiceGraph { ...@@ -94,6 +97,8 @@ impl ServiceGraph {
} }
// Allow for less time spent locking and unlocking the graph // Allow for less time spent locking and unlocking the graph
// Ofc `self.graph.read()` and `graph` are probably going to
// end up the same, the point is to prevent lots of unessasary locking.
fn start_service_with_graph(&self, graph: &DepGraph<Service>, index: Index) -> Result<(), Error> { fn start_service_with_graph(&self, graph: &DepGraph<Service>, index: Index) -> Result<(), Error> {
let service = graph.get(index) let service = graph.get(index)
.ok_or(err_msg("service not found"))?; .ok_or(err_msg("service not found"))?;
...@@ -119,7 +124,7 @@ impl ServiceGraph { ...@@ -119,7 +124,7 @@ impl ServiceGraph {
for group in resolved.iter() { for group in resolved.iter() {
//TODO: Use par_iter() if rayon will work on redox //TODO: Use par_iter() if rayon will work on redox
group.iter().for_each(|index| { group.par_iter().for_each(|index| {
self.start_service_with_graph(&graph, *index) self.start_service_with_graph(&graph, *index)
.unwrap_or_else(|err| { error!("error starting service: {}", err) }); .unwrap_or_else(|err| { error!("error starting service: {}", err) });
}); });
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment