Customizing cont.new with stack size
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Feature
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- wasm
- Bereich
- compilers
Rechercherichtung
Start by reviewing the cont.new instruction and the proposal's existing stack-switching semantics. Compare the listed stack-allocation strategies, then determine whether the small-coroutine marker, its minimum stack guarantee, and the well-defined overflow exception can be specified consistently. Done requires an agreed proposal-level design rather than a single localized edit.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
One of the trickiest issues to solve in stack switching is how big a stack to allocate for the new coroutine. Empirically, it has been observed that coroutines' memory requirements are often wildly divergent with some (perhaps most) coroutines only needing a small amount of memory to complete their task.
There are several ways of dealing with this:
- use fixed size stacks that are the same size as the default stack.
- implement a strategy for automatically growing stacks
- allow the user (toolchain) to specify the size of the stack for the new coroutine.
The advantages of these different approaches include:
- Simplicity of implementation.
- Sensitivity to actual computation requirements; in addition, the default size of a stack can be set to a small value -- allowing an application to have large numbers of suspended computations.
- The application author may be the best source of actual knowledge about the expected size of a task. Allowing the toolchain to express this facilitates this.
Each of these also has disadvantages:
- Particularly on limited memory platforms (such as mobile devices) there may not be enough address space to accommodate large numbers of large stacks.
- Automatically growing stacks is complex to realize (a stack overflow can occur in code that was not compiled for coroutining) and significantly increases the attack surface for security vulnerabilities.
- the toolchain may not know how much space to allocate for the stack. In particular, WebAssembly does not expose this information -- for good reasons. In addition, the toolchain may guess incorrectly.
A proposal:
allow a form of coarse grain estimation of the expected size of a coroutine, and throw a well defined exception when the actual computation is too large.
I suggest simply adding a marker to the cont.new instruction that declares that "the coroutine is small". This would allow the engine to allocate a small stack structure for that coroutine.
How small is small?
This may be implementation defined; however, I suggest that a more rigorous approach would be to specify a minimum amount of stack space would be available. This could be expressed in bytes but higher level, engine independent way, would be to state this as a combination of frames and local variables.
This approach would allow toolchains to optimize the overall memory footprint of generated applications whilst also allowing for some large stacks. One might imagine, for example, that when implementing generators most coroutines would be marked as small, whereas the default for green threads would be normal sized stacks.
- Vorherrschende Sprache
- WebAssembly
- Sterne
- 218
- Forks
- 19
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus WebAssembly/stack-switching
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
WebAssembly/stack-switching#145 · 4 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
WebAssembly/stack-switching#144 · 4 Kommentare ·
-
JSPI integrationOffen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
WebAssembly/stack-switching#131 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 45/100
WebAssembly/stack-switching#128 · 6 Kommentare ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
WebAssembly/stack-switching#122 · 3 Kommentare ·
Alle Issues in WebAssembly/stack-switching
Ähnliche Issues
-
area:codegen backend:cuda backend:hip bug direction:input
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
CrossGL/crosstl#3061 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
build
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
AOMediaCodec/SVT-AV1#2500 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
rescript-lang/rescript#9037 ·
Maintainer antworten meist innerhalb von 1 Tag