Skip to content

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Oct 11, 2022

Previously we defaulted to 1 in this case, but we want to improve the error reporting around stack overflow in preparation for lowering the default stack size. See #14177

Benchmark results:

                     Node.js_no_stack_check	Node.js_with_stack_check
              base64 1.000	0.972
        conditionals 1.000	1.096
                copy 1.000	1.003
         corrections 1.000	0.982
       corrections64 1.000	1.004
            fannkuch 1.000	1.004
         fasta_float 1.000	1.002
              havlak 1.000	1.025
                 ifs 1.000	0.962
     matrix_multiply 1.000	1.021
              memops 1.000	0.988
              primes 1.000	0.914
      primes_nocheck 1.000	1.113
            skinning 1.000	0.914
           zzz_box2d 1.000	1.076
          zzz_bullet 1.000	0.988
        zzz_coremark 1.000	0.981
         zzz_linpack 1.000	1.001
 zzz_lua_binarytrees 1.000	1.049
     zzz_lua_scimark 1.000	1.060
            zzz_lzma 1.000	0.984
         zzz_poppler 1.000	1.047
          zzz_sqlite 1.000	1.026
            zzz_zlib 1.000	0.996

@sbc100 sbc100 force-pushed the stack_check_default branch from b802c8a to a072a74 Compare October 12, 2022 00:56
Previously we defaulted to 1 in this case, but we want to improve the
error reporting around stack overflow in preparation for lowering the
default stack size. See #14177

I ran the benchmark test suite under node and could not measure any
significant effect:
@sbc100 sbc100 force-pushed the stack_check_default branch from a072a74 to 650e8c6 Compare October 12, 2022 01:31
@sbc100 sbc100 requested review from dschuff and kripken October 12, 2022 20:27
@kripken
Copy link
Member

kripken commented Oct 12, 2022

Are the benchmarks comparing -sASSERTIONS before and after this PR (with the benchmarks modified to enable assertions), or do they compare -O3 -sSTACK_OVERFLOW_CHECK=1 vs -O3 -sSTACK_OVERFLOW_CHECK=2, or something else?

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably makes sense to do, since performance in debug builds isn't critical, and it looks like this is not a significant regression there anyhow.

if self.get_setting('MEMORY64') == 2:
self.skipTest('MEMORY64=2 always requires module re-writing')
self.set_setting('WASM_BIGINT')
self.set_setting('STACK_OVERFLOW_CHECK', 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these just to add more test coverage? Or is it necessary for some reason? Please add a comment.

required_flags = ['-sWASM_BIGINT']
# -O0 with BigInt support (to avoid the need for legalization) and STACK_OVERFLOW_CHECK=1 (to
# avoid the need for the stack check pass).
required_flags = ['-sWASM_BIGINT', '-sSTACK_OVERFLOW_CHECK=1']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this means the default build will still do wasm changes after link even after we default to wasm-bigint. Maybe it makes sense though.

Please add to this test. We want to emit a good error message in this case, that is, ERROR_ON_WASM_CHANGES_AFTER_LINK should do like it does with WASM_BIGINT - if it's not set right, suggest the proper value.

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 12, 2022

Are the benchmarks comparing -sASSERTIONS before and after this PR (with the benchmarks modified to enable assertions), or do they compare -O3 -sSTACK_OVERFLOW_CHECK=1 vs -O3 -sSTACK_OVERFLOW_CHECK=2, or something else?

These benchmarks are actually from main I ran with:

a: ['-sASSERTIONS', '-sSTACK_OVERFLOW_CHECK=1']
b: ['-sASSERTIONS', '-sSTACK_OVERFLOW_CHECK=2']

@kripken
Copy link
Member

kripken commented Oct 12, 2022

Are those flags on top of -O3 or something else? Or are those all the flags passed to emcc?

@sbc100
Copy link
Collaborator Author

sbc100 commented Oct 13, 2022

Are those flags on top of -O3 or something else? Or are those all the flags passed to emcc?

I think they are on top of -O3.

EmscriptenBenchmarker('Node.js no stack check', config.NODE_JS, ['-sASSERTIONS', '-sSTACK_OVERFLOW_CHECK=1'])

I think the EmscriptenBenchmarker injects OPTIMIZATIONS in addition to these flags, right?

@kripken
Copy link
Member

kripken commented Oct 13, 2022

Yes, that sounds right.

@sbc100
Copy link
Collaborator Author

sbc100 commented Nov 13, 2022

Closing a favor of #18154. After speaking with @dschuff we decided we really didn't want to add any binaryen passed to debug builds by default since that would inhibit that ability to skip binaryen rewriting completely (which is very important for fast debug link times)

@sbc100 sbc100 closed this Nov 30, 2022
@sbc100 sbc100 deleted the stack_check_default branch November 30, 2022 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants