rust/library/std/src
Manish Goregaokar b4615b5bf9
Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se
Rename `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`

_Tracking issue: https://github.com/rust-lang/rust/issues/74479_

This PR renames  `std:🧵:available_conccurrency` to `std:🧵:available_parallelism`.

## Rationale

The API was initially named `std:🧵:hardware_concurrency`, mirroring the [C++ API of the same name](https://en.cppreference.com/w/cpp/thread/thread/hardware_concurrency). We eventually decided to omit any reference to the word "hardware" after [this comment](https://github.com/rust-lang/rust/pull/74480#issuecomment-662045841). And so we ended up with `available_concurrency` instead.

---

For a talk I was preparing this week I was reading through ["Understanding and expressing scalable concurrency" (A. Turon, 2013)](http://aturon.github.io/academic/turon-thesis.pdf), and the following passage stood out to me (emphasis mine):

> __Concurrency is a system-structuring mechanism.__ An interactive system that deals with disparate asynchronous events is naturally structured by division into concurrent threads with disparate responsibilities. Doing so creates a better fit between problem and solution, and can also decrease the average latency of the system by preventing long-running computations from obstructing quicker ones.

> __Parallelism is a resource.__ A given machine provides a certain capacity for parallelism, i.e., a bound on the number of computations it can perform simultaneously. The goal is to maximize throughput by intelligently using this resource. For interactive systems, parallelism can decrease latency as well.

_Chapter 2.1: Concurrency is not Parallelism. Page 30._

---

_"Concurrency is a system-structuring mechanism. Parallelism is a resource."_ — It feels like this accurately captures the way we should be thinking about these APIs. What this API returns is not "the amount of concurrency available to the program" which is a property of the program, and thus even with just a single thread is effectively unbounded. But instead it returns "the amount of _parallelism_ available to the program", which is a resource hard-constrained by the machine's capacity (and can be further restricted by e.g. operating systems).

That's why I'd like to propose we rename this API from `available_concurrency` to `available_parallelism`. This still meets the criteria we previously established of not attempting to define what exactly we mean by "hardware", "threads", and other such words. Instead we only talk about "concurrency" as an abstract resource available to our program.

r? `@joshtriplett`
2021-10-06 12:33:17 -07:00
..
backtrace Add Frames iterator for Backtrace 2021-01-23 11:56:33 -06:00
collections Stabilize try_reserve 2021-10-04 10:29:46 +01:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f32 More lerp tests, altering lerp docs 2021-06-13 14:00:15 -04:00
f64 More lerp tests, altering lerp docs 2021-06-13 14:00:15 -04:00
ffi Clarify that CString::from_vec_unchecked appends 0 byte. 2021-09-28 05:51:52 +05:00
fs Fix may not to appropriate might not or must not 2021-07-29 01:15:20 -04:00
io Rollup merge of #87601 - a1phyr:feature_uint_add_signed, r=kennytm 2021-10-06 12:33:13 -07:00
lazy Upgrade wasm32 image to Ubuntu 20.04 2021-02-06 13:05:56 +01:00
net Rollup merge of #89138 - newpavlov:patch-2, r=dtolnay 2021-10-03 23:13:21 -07:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Add SOLID targets 2021-09-28 11:31:47 +09:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path path.push() should work as expected on windows verbatim paths 2021-10-01 19:54:57 +01:00
prelude Move asm! and global_asm! to core::arch 2021-07-18 18:30:58 -04:00
process Test that env_clear works on Windows 2021-06-24 09:32:24 +01:00
sync Practice diagnostic message convention 2021-10-03 16:16:28 +09:00
sys Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se 2021-10-06 12:33:17 -07:00
sys_common Merge two THREAD_INFO.with and following RefCell borrow 2021-09-16 15:24:53 +02:00
thread Rollup merge of #89324 - yoshuawuyts:hardware-parallelism, r=m-ou-se 2021-10-06 12:33:17 -07:00
time Rollup merge of #88651 - AGSaidi:monotonize-inner-64b-aarch64, r=dtolnay 2021-10-04 23:56:17 -07:00
alloc.rs Rename rterr to rtprintpanic 2021-05-19 15:52:09 +02:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs Fix may not to appropriate might not or must not 2021-07-29 01:15:20 -04:00
env.rs library/std/env: Add 'm68k' to comment on ARCH constant 2021-09-17 15:07:14 +00:00
error.rs Stabilize try_reserve 2021-10-04 10:29:46 +01:00
f32.rs Fix may not to appropriate might not or must not 2021-07-29 01:15:20 -04:00
f64.rs Fix may not to appropriate might not or must not 2021-07-29 01:15:20 -04:00
fs.rs Auto merge of #89165 - jkugelman:read-to-end-overallocation, r=joshtriplett 2021-10-04 04:44:56 +00:00
keyword_docs.rs Fix typo in break docs 2021-09-16 14:51:14 +03:00
lazy.rs PR fixup 2021-09-22 05:17:30 -04:00
lib.rs Rollup merge of #87601 - a1phyr:feature_uint_add_signed, r=kennytm 2021-10-06 12:33:13 -07:00
macros.rs bump bootstrap compiler to 1.55 2021-08-01 11:19:24 -04:00
num.rs Add Saturating type (based on Wrapping type) 2021-08-10 19:27:01 +02:00
panic.rs Allow panic!("{}", computed_str) in const fn. 2021-09-15 21:56:43 +01:00
panicking.rs Bump stage0 compiler to 1.56 2021-09-08 20:51:05 -04:00
path.rs path.push() should work as expected on windows verbatim paths 2021-10-01 19:54:57 +01:00
primitive_docs.rs Add primitive documentation to libcore 2021-09-12 02:23:08 +00:00
process.rs Merge sys_common::rt into rt 2021-09-16 14:32:32 +02:00
rt.rs Auto merge of #89011 - bjorn3:restructure_rt, r=dtolnay 2021-09-29 17:58:08 +00:00
time.rs Auto merge of #86191 - kawadakk:release-add-solid-support, r=nagisa,estebank,m-ou-se, 2021-09-28 11:50:33 +00:00