Commit fcedb00
Optimization: Vendor jobserver impl and rm thread spawning in parallel compile_objects (#889)
* Impl vendored jobserver implementation
It supports non-blocking `try_acquire` and is much simpler than the one
provided by `jobserver`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Convert parallel `compile_objects` to use future instead of threads
Also fixed compilation errors in mod `job_token`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Optimize parallel `compile_objects`
Remove use of mpsc since the future is executed on one single thread
only.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Fix `job_token`: Remove mpsc and make sure tokens are relased
The mpsc is stored in a global variable and Rust never calls
`Drop::drop` on global variables, so they are never released.
This commit removes the mpsc and replaces that with an `AtomicBool` for
the implicit token to fix this, also dramatically simplifies the code.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Optimize `job_token`: Make `JobToken` zero-sized
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Fix `windows::JobServerClient::try_acquire` impl
Return `Ok(None)` instead of `Err()` if no token is ready.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Fix `unix::JobServerClient::from_pipe`: Accept more fd access modes
`O_RDWR` is a valid access mode for both read and write end of the pipe.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Rm unnecessary `'static` bound in parameter of `job_token`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Optimize parallel `compile_objects`: Sleep/yield if no progress is made
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Fix windows implementation: Match all return value explicitly
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Use Result::ok() in job_token.rs
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
* Fix grammer in comments
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
* simplify job_token impl
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
* Add more comment explaining the design choice
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Refactor: Extract new mod `async_executor`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Update src/job_token/unix.rs
Co-authored-by: Thom Chiovoloni <thom@shift.click>
* Remove outdated comment
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Do not check for `--jobserver-fds` on windows
Since the manual specifies that only `--jobsewrver-auth` will be used
and windows does not have the concept of fds anyway.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Accept ASCII only in windows `JobServerClient::open` impl
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Use acquire and release ordering for atomic operation in `JobServer`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Add a TODO for use of `NUM_JOBS`
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
* Simplify windows jobserver `WAIT_ABANDONED` errmsg
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
---------
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Thom Chiovoloni <thom@shift.click>1 parent bd25128 commit fcedb00
File tree
8 files changed
+644
-206
lines changed- gen-windows-sys-binding
- src
- job_token
8 files changed
+644
-206
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 21 | | |
25 | 22 | | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
29 | 26 | | |
30 | | - | |
| 27 | + | |
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
9 | 15 | | |
10 | 16 | | |
11 | 17 | | |
| |||
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
0 commit comments