fitzgen opened Issue #1883:
Enabling stack maps and GC safepoints adds another pass over the IR (
emit_stackmaps
) regardless whether the function in question actually uses reference types at all. One could imagine (especially with wasm-bindgen's "switch reference types into table indices at the boundaries" approach, that seems likely to be copied by C/C++) that many functions in a module don't use reference types. For these functions, that extra pass over the IR is a waste of time.We could have a flag on functions that gets set if it uses reference types in any way (and then never gets unset when a particular reference type-using instruction is removed, so we don't have to precisely count them) and in
emit_stackmaps
, only walk the IR if the flag is set (and probablydebug_assert!
that it doesn't have any uses of reference types if the flag is not set).This came up in https://github.com/bytecodealliance/wasmtime/pull/1832#discussion_r440456291 for Wasmtime.
fitzgen labeled Issue #1883:
Enabling stack maps and GC safepoints adds another pass over the IR (
emit_stackmaps
) regardless whether the function in question actually uses reference types at all. One could imagine (especially with wasm-bindgen's "switch reference types into table indices at the boundaries" approach, that seems likely to be copied by C/C++) that many functions in a module don't use reference types. For these functions, that extra pass over the IR is a waste of time.We could have a flag on functions that gets set if it uses reference types in any way (and then never gets unset when a particular reference type-using instruction is removed, so we don't have to precisely count them) and in
emit_stackmaps
, only walk the IR if the flag is set (and probablydebug_assert!
that it doesn't have any uses of reference types if the flag is not set).This came up in https://github.com/bytecodealliance/wasmtime/pull/1832#discussion_r440456291 for Wasmtime.
github-actions[bot] commented on Issue #1883:
Subscribe to Label Action
cc @bnjbvr
<details>
This issue or pull request has been labeled: "cranelift"Thus the following users have been cc'd because of the following labels:
- bnjbvr: cranelift
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
bnjbvr commented on Issue #1883:
Thanks for opening an issue! Do you have any numbers on how much relative time is spent going over the IR, for a large module? This would help quantifying how urgent an issue it is. In any case, agreed that not doing wasteful work is generally good, of course.
The idea of using a flag on the function sounds good. Not sure where to put it, since as far as i can tell it's the first usage of a flag in a Function; could be directly there, or DataFlowGraph, etc.
fitzgen commented on Issue #1883:
Not sure how much time is spent doing the pass when there aren't any reference types used, it just came up during review.
fitzgen closed Issue #1883:
Enabling stack maps and GC safepoints adds another pass over the IR (
emit_stackmaps
) regardless whether the function in question actually uses reference types at all. One could imagine (especially with wasm-bindgen's "switch reference types into table indices at the boundaries" approach, that seems likely to be copied by C/C++) that many functions in a module don't use reference types. For these functions, that extra pass over the IR is a waste of time.We could have a flag on functions that gets set if it uses reference types in any way (and then never gets unset when a particular reference type-using instruction is removed, so we don't have to precisely count them) and in
emit_stackmaps
, only walk the IR if the flag is set (and probablydebug_assert!
that it doesn't have any uses of reference types if the flag is not set).This came up in https://github.com/bytecodealliance/wasmtime/pull/1832#discussion_r440456291 for Wasmtime.
Last updated: Nov 22 2024 at 16:03 UTC