Skip to content

Commit 9ea0e75

Browse files
authored
Remove Preview1's advice about random-number generators. (#664)
Previously, the preview1 documentation for the `random_get` function said: > This function may execute slowly, so when large mounts of random data are > required, it's advisable to use this function to seed a pseudo-random > number generator, rather than to provide the random data directly. However, Wasm guest code is unaware of VM forks in any VMs might be running in, as well as snapshot/resume features offered by some Wasm engines and tools, so in practice, WASI use cases have tended toward using `random_get` in place of guest PRNGs, and thus to relying on `random_get` executing quickly. This pattern seems sufficiently widely applicable to motivate updating WASIp1 to reflect it. To be sure, this is not a behavior change; it's just removing what we now understand to be bad advice in general. WASIp2 for its part has already made a similar change.
1 parent 8ee4188 commit 9ea0e75

File tree

5 files changed

+1
-13
lines changed

5 files changed

+1
-13
lines changed

legacy/preview0/docs.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,9 +2394,6 @@ Note: This is similar to [`sched_yield`](#sched_yield) in POSIX.
23942394
Write high-quality random data into a buffer.
23952395
This function blocks when the implementation is unable to immediately
23962396
provide sufficient high-quality random data.
2397-
This function may execute slowly, so when large mounts of random data are
2398-
required, it's advisable to use this function to seed a pseudo-random
2399-
number generator, rather than to provide the random data directly.
24002397

24012398
##### Params
24022399
- <a href="#random_get.buf" name="random_get.buf"></a> `buf`: `Pointer<u8>`

legacy/preview0/witx/wasi_unstable.witx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,6 @@
466466
;;; Write high-quality random data into a buffer.
467467
;;; This function blocks when the implementation is unable to immediately
468468
;;; provide sufficient high-quality random data.
469-
;;; This function may execute slowly, so when large mounts of random data are
470-
;;; required, it's advisable to use this function to seed a pseudo-random
471-
;;; number generator, rather than to provide the random data directly.
472469
(@interface func (export "random_get")
473470
;;; The buffer to fill with random data.
474471
(param $buf (@witx pointer u8))

legacy/preview1/docs.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ <h5 id="results">Results</h5>
12111211
</ul>
12121212
<hr>
12131213
<h4 id="a-href-random_get-name-random_get-a-random_get-buf-pointeru8-buf_len-size-errno">&lt;a href=&quot;#random_get&quot; name=&quot;random_get&quot;&gt;&lt;/a&gt; <code>random_get(buf: Pointer&lt;u8&gt;, buf_len: size) -&gt; errno</code></h4>
1214-
<p>Write high-quality random data into a buffer.<br>This function blocks when the implementation is unable to immediately<br>provide sufficient high-quality random data.<br>This function may execute slowly, so when large mounts of random data are<br>required, it&#39;s advisable to use this function to seed a pseudo-random<br>number generator, rather than to provide the random data directly.</p>
1214+
<p>Write high-quality random data into a buffer.<br>This function blocks when the implementation is unable to immediately<br>provide sufficient high-quality random data.</p>
12151215
<h5 id="params">Params</h5>
12161216
<ul>
12171217
<li><p>&lt;a href=&quot;#random_get.buf&quot; name=&quot;random_get.buf&quot;&gt;&lt;/a&gt; <code>buf</code>: <code>Pointer&lt;u8&gt;</code><br>The buffer to fill with random data.</p>

legacy/preview1/docs.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,9 +2422,6 @@ Note: This is similar to [`sched_yield`](#sched_yield) in POSIX.
24222422
Write high-quality random data into a buffer.
24232423
This function blocks when the implementation is unable to immediately
24242424
provide sufficient high-quality random data.
2425-
This function may execute slowly, so when large mounts of random data are
2426-
required, it's advisable to use this function to seed a pseudo-random
2427-
number generator, rather than to provide the random data directly.
24282425

24292426
##### Params
24302427
- <a href="#random_get.buf" name="random_get.buf"></a> `buf`: `Pointer<u8>`

legacy/preview1/witx/wasi_snapshot_preview1.witx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,6 @@
485485
;;; Write high-quality random data into a buffer.
486486
;;; This function blocks when the implementation is unable to immediately
487487
;;; provide sufficient high-quality random data.
488-
;;; This function may execute slowly, so when large mounts of random data are
489-
;;; required, it's advisable to use this function to seed a pseudo-random
490-
;;; number generator, rather than to provide the random data directly.
491488
(@interface func (export "random_get")
492489
;;; The buffer to fill with random data.
493490
(param $buf (@witx pointer u8))

0 commit comments

Comments
 (0)