Skip to content

Commit a0bc232

Browse files
sunfishcodelukewagner
authored andcommitted
Rename hw_concurrency to available_parallelism.
Following the general computer-science meanings of the terms "concurrency" and "parallelism", rename `thread.hw_concurrency` to `thread.available_parallelism`, because it's about the number of threads that can execute in parallel. This differs from the existing JS API of [`navigator.hardwareConcurrency`], so add a note mentioning the correspondence. [`navigator.hardwareConcurrency`]: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hardwareConcurrency
1 parent 03ea29d commit a0bc232

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

design/mvp/Binary.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ canon ::= 0x00 0x00 f:<core:funcidx> opts:<opts> ft:<typeidx> => (canon lift
287287
| 0x07 rt:<typdidx> => (canon resource.drop rt async (core func))
288288
| 0x04 rt:<typeidx> => (canon resource.rep rt (core func))
289289
| 0x05 ft:<typeidx> => (canon thread.spawn ft (core func)) 🧵
290-
| 0x06 => (canon thread.hw_concurrency (core func)) 🧵
290+
| 0x06 => (canon thread.available_concurrency (core func)) 🧵
291291
| 0x08 => (canon task.backpressure (core func)) 🔀
292292
| 0x09 ft:<core:typeidx> => (canon task.return ft (core func)) 🔀
293293
| 0x0a async?:<async>? m:<core:memdix> => (canon task.wait async? (memory m) (core func)) 🔀

design/mvp/CanonicalABI.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -3418,22 +3418,22 @@ def canon_thread_spawn(f, c):
34183418
return [-1]
34193419
```
34203420

3421-
### 🧵 `canon thread.hw_concurrency`
3421+
### 🧵 `canon thread.available_parallelism`
34223422

34233423
For a canonical definition:
34243424
```wasm
3425-
(canon thread.hw_concurrency (core func $f))
3425+
(canon thread.available_parallelism (core func $f))
34263426
```
34273427
validation specifies:
34283428
* `$f` is given type `(func shared (result i32))`.
34293429

34303430
Calling `$f` returns the number of threads the underlying hardware can be
3431-
expected to execute concurrently. This value can be artificially limited by
3431+
expected to execute in parallel. This value can be artificially limited by
34323432
engine configuration and is not allowed to change over the lifetime of a
34333433
component instance.
34343434

34353435
```python
3436-
def canon_thread_hw_concurrency():
3436+
def canon_thread_available_parallelism():
34373437
if DETERMINISTIC_PROFILE:
34383438
return [1]
34393439
else:

design/mvp/Explainer.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -1422,7 +1422,7 @@ canon ::= ...
14221422
| (canon error-context.debug-message <canonopt>* (core func <id>?))
14231423
| (canon error-context.drop (core func <id>?))
14241424
| (canon thread.spawn <typeidx> (core func <id>?)) 🧵
1425-
| (canon thread.hw_concurrency (core func <id>?)) 🧵
1425+
| (canon thread.available_parallelism (core func <id>?)) 🧵
14261426
```
14271427

14281428
##### Resource built-ins
@@ -1864,17 +1864,21 @@ of `c` is currently hard-coded to always be `i32`.
18641864

18651865
(See also [`canon_thread_spawn`] in the Canonical ABI explainer.)
18661866

1867-
###### 🧵 `thread.hw_concurrency`
1867+
###### 🧵 `thread.available_parallelism`
18681868

18691869
| Synopsis | |
18701870
| -------------------------- | --------------- |
18711871
| Approximate WIT signature | `func() -> u32` |
18721872
| Canonical ABI signature | `[] -> [i32]` |
18731873

1874-
The `thread.hw_concurrency` built-in returns the number of threads that can be
1875-
expected to execute concurrently.
1874+
The `thread.available_parallelism` built-in returns the number of threads that can be
1875+
expected to execute in parallel.
18761876

1877-
(See also [`canon_thread_hw_concurrency`] in the Canonical ABI explainer.)
1877+
The concept of "available parallelism" corresponds is sometimes referred to
1878+
as "hardware concurrency", such as in [`navigator.hardwareConcurrency`] in
1879+
JavaScript.
1880+
1881+
(See also [`canon_thread_available_parallelism`] in the Canonical ABI explainer.)
18781882

18791883
### 🪙 Value Definitions
18801884

@@ -2702,7 +2706,7 @@ For some use-case-focused, worked examples, see:
27022706
[`canon_error_context_debug_message`]: CanonicalABI.md#-canon-error-contextdebug-message
27032707
[`canon_error_context_drop`]: CanonicalABI.md#-canon-error-contextdrop
27042708
[`canon_thread_spawn`]: CanonicalABI.md#-canon-theadspawn
2705-
[`canon_thread_hw_concurrency`]: CanonicalABI.md#-canon-threadhw_concurrency
2709+
[`canon_thread_available_parallelism`]: CanonicalABI.md#-canon-threadavailable_parallelism
27062710
[`pack_async_copy_result`]: CanonicalABI.md#-canon-streamfuturereadwrite
27072711
[the `close` built-ins]: CanonicalABI.md#-canon-streamfutureclose-readablewritable
27082712
[Shared-Nothing]: ../high-level/Choices.md
@@ -2717,3 +2721,5 @@ For some use-case-focused, worked examples, see:
27172721

27182722
[Scoping and Layering]: https://docs.google.com/presentation/d/1PSC3Q5oFsJEaYyV5lNJvVgh-SNxhySWUqZ6puyojMi8
27192723
[Future and Stream Types]: https://docs.google.com/presentation/d/1MNVOZ8hdofO3tI0szg_i-Yoy0N2QPU2C--LzVuoGSlE
2724+
2725+
[`navigator.hardwareConcurrency`]: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/hardwareConcurrency

0 commit comments

Comments
 (0)