Skip to content

Make it easier to detect thread pool exhaustion - #13591

Merged
sbc100 merged 11 commits into
mainfrom
thread-pool-exhaustion
Mar 11, 2021
Merged

sbc100 merged 11 commits into
mainfrom
thread-pool-exhaustion

Conversation

@RReverser

@RReverser RReverser commented Mar 3, 2021 •

Copy link
Copy Markdown
Collaborator

Off-the-shelf C++ code doesn't know anything about JS event loop, and "normal" usages of pthread_create + pthread_join or any form of locks just deadlock silently.

This frequently leads to user confusion and those issues are not the easiest to debug. Some long-term solutions were proposed in #9910 and in #11554 (comment), but they require more design work.

For now this can at least fix #11554 and 1) warn users that the thread pool is exhausted in debug builds (-s ASSERTIONS=1) and 2) add an option PTHREAD_POOL_SIZE_STRICT to make such exhaustion a hard error in release builds for users who don't expect to create any more threads than preconfigured during the build time.


Example output before/after:

rreverser@rreverser:~/emscripten$ emcc temp.cpp -o temp.js -pthread
rreverser@rreverser:~/emscripten$ node --experimental-wasm-threads --experimental-wasm-bulk-memory temp.js
Before Thread
^C # cancelled because app was locked

rreverser@rreverser:~/emscripten$ ./emcc temp.cpp -o temp.js -pthread
rreverser@rreverser:~/emscripten$ node --experimental-wasm-threads --experimental-wasm-bulk-memory temp.js
Before Thread
Tried to spawn a new thread, but the thread pool is exhausted.
This will result in a deadlock unless the code explicitly breaks out to the event loop.
If you want to increase the pool size, use setting `-s PTHREAD_POOL_SIZE=...`.
If you want to throw an explicit error instead of deadlocking in those cases, use setting `-s PTHREAD_POOL_SIZE_STRICT=1`.
^C # cancelled because app was locked

rreverser@rreverser:~/emscripten$ ./emcc temp.cpp -o temp.js -pthread -s PTHREAD_POOL_SIZE_STRICT=1
rreverser@rreverser:~/emscripten$ node --experimental-wasm-threads --experimental-wasm-bulk-memory temp.js
Before Thread
Tried to spawn a new thread, but the thread pool is exhausted.
This will result in a deadlock unless the code explicitly breaks out to the event loop.
If you want to increase the pool size, use setting `-s PTHREAD_POOL_SIZE=...`.
exception thrown: Error: No available workers in the PThread pool,Error: No available workers in the PThread pool
    at Object.getNewWorker (/usr/local/google/home/rreverser/emscripten/temp.js:2173:17)
    at spawnThread (/usr/local/google/home/rreverser/emscripten/temp.js:2982:28)
    at _pthread_create (/usr/local/google/home/rreverser/emscripten/temp.js:3138:9)
    at <anonymous>:wasm-function[25]:0x923
    at main (<anonymous>:wasm-function[26]:0x956)
    at /usr/local/google/home/rreverser/emscripten/temp.js:1639:22
    at callMain (/usr/local/google/home/rreverser/emscripten/temp.js:3655:15)
    at doRun (/usr/local/google/home/rreverser/emscripten/temp.js:3732:23)
    at run (/usr/local/google/home/rreverser/emscripten/temp.js:3747:5)
    at runCaller (/usr/local/google/home/rreverser/emscripten/temp.js:3633:19)

rreverser@rreverser:~/emscripten$ ./emcc temp.cpp -o temp.js -pthread -s PTHREAD_POOL_SIZE_STRICT=1 -s ASSERTIONS=0
rreverser@rreverser:~/emscripten$ node --experimental-wasm-threads --experimental-wasm-bulk-memory temp.js
Before Thread
exception thrown: Error: No available workers in the PThread pool,Error: No available workers in the PThread pool
    at Object.getNewWorker (/usr/local/google/home/rreverser/emscripten/temp.js:1892:17)
    at spawnThread (/usr/local/google/home/rreverser/emscripten/temp.js:2676:28)
    at _pthread_create (/usr/local/google/home/rreverser/emscripten/temp.js:2832:9)
    at <anonymous>:wasm-function[25]:0x8be
    at main (<anonymous>:wasm-function[26]:0x8f1)
    at Module._main (/usr/local/google/home/rreverser/emscripten/temp.js:2985:60)
    at callMain (/usr/local/google/home/rreverser/emscripten/temp.js:3156:15)
    at doRun (/usr/local/google/home/rreverser/emscripten/temp.js:3222:23)
    at run (/usr/local/google/home/rreverser/emscripten/temp.js:3237:5)
    at runCaller (/usr/local/google/home/rreverser/emscripten/temp.js:3136:19)
# thrown a hard error and exited without long warning

Another alternative I considered was untying this warning from ASSERTIONS. There are two reasons to go that route:

  1. This is not always an error and advanced users who return to event loop between thread creation & usage might want to disable this particular warning separately from other assertions.
  2. Majority of users might want to see at least a warning even in release builds where other assertions are disabled, since number of threads can depend on the input data.

If that's an acceptable option, then I'd instead define PTHREAD_POOL_SIZE_STRICT as follows:

  • -s PTHREAD_POOL_SIZE_STRICT=0 -> no warnings for users who know what they're doing and adapted their code to break out to the event loop
  • -s PTHREAD_POOL_SIZE_STRICT=1 -> default option, show warning but still try to create a thread, so that users at least know why there's a deadlock if it occurs
  • -s PTHREAD_POOL_SIZE_STRICT=2 -> for users who saw the warning and decided to go all-in on the limit, as they are just trying to compile a code to the Web and don't want to mess with event loop APIs

@RReverser
RReverser requested review from dschuff, kripken and sbc100 March 3, 2021 19:18

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is great in general!

I'm not convinced we need to show this kind of thing in release builds. Maybe we could compromise and throw new Error('no workers available'); in release builds? (to avoid adding that long warning string)

Comment thread src/library_pthread.js Resolved
Comment thread src/settings.js Resolved
@RReverser

Copy link
Copy Markdown
Collaborator Author

I'm not convinced we need to show this kind of thing in release builds. Maybe we could compromise and throw new Error('no workers available'); in release builds? (to avoid adding that long warning string)

Do you mean just to save code size? Yeah sounds reasonable.

@RReverser

Copy link
Copy Markdown
Collaborator Author

I'm not convinced we need to show this kind of thing in release builds. Maybe we could compromise and throw new Error('no workers available'); in release builds? (to avoid adding that long warning string)

Do you mean just to save code size? Yeah sounds reasonable.

Done (but still made error message a little more googlable).

@RReverser

RReverser commented Mar 3, 2021 •

Copy link
Copy Markdown
Collaborator Author

@sbc100 I think I addressed your comments; I'd also love to hear your thought on the last part of the PR description - WDYT about detaching PTHREAD_POOL_SIZE_STRICT= into its own setting separately from ASSERTIONS?

@RReverser

Copy link
Copy Markdown
Collaborator Author

I'm not convinced we need to show this kind of thing in release builds.

FWIW the reason I think this is important is that we discovered this only in prod on Squoosh, where apparently codec creates extra threads only for some images but not others (depending on the content). Having an error in this case would help a lot more than users just waiting for encoding to finish and reporting encoder as "slow" when it's in fact deadlocked on that specific input.

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like this change a lot now.

Probably should have a test, but otherwise lgtm.

Comment thread src/library_pthread.js Resolved
@RReverser

RReverser commented Mar 3, 2021 •

Copy link
Copy Markdown
Collaborator Author

Yeah a test would be good. I still wanted to hear thoughts on the alternative before adding one though.

(Also: how do I test error messages in btest?)

@sbc100

sbc100 commented Mar 3, 2021

Copy link
Copy Markdown
Collaborator

@sbc100 I think I addressed your comments; I'd also love to hear your thought on the last part of the PR description - WDYT about detaching PTHREAD_POOL_SIZE_STRICT= into its own setting separately from ASSERTIONS?

Even though I generally avoid adding new settings, I agree that having this available in production is useful so tying it only to ASSERTIONS seems wrong. Also enabling always in wrong... so it seems a new settings is unavoidable.

Is there are shorter or more descriptive name for this new setting we can come up with? .. I can't think of one.

@RReverser

RReverser commented Mar 3, 2021 •

Copy link
Copy Markdown
Collaborator Author

Is there are shorter or more descriptive name for this new setting we can come up with? .. I can't think of one.

Me neither, but open to suggestions... Maybe something like PTHREAD_POOL_ONLY / PTHREAD_ONLY_POOLED?

@sbc100

sbc100 commented Mar 3, 2021

Copy link
Copy Markdown
Collaborator

Is there are shorter or more descriptive name for this new setting we can come up with? .. I can't think of one.

Me neither, but open to suggestions... Maybe something like PTHREAD_POOL_ONLY / PTHREAD_ONLY_POOLED?

PTHREAD_POOL_ONLY sounds good. PTHREAD_REQUIRE_POOL? PTHREAD_NO_SYNC_CREATE?

@RReverser

Copy link
Copy Markdown
Collaborator Author

PTHREAD_REQUIRE_POOL makes it sound like it's enough to have a pool, which it isn't, but the other two sgtm.

@RReverser

Copy link
Copy Markdown
Collaborator Author

Meanwhile I tried to work around the Squoosh issue with PROXY_TO_PTHREAD, but ran into more issues: #13595 :D

I think that's it for me for today.

Comment thread src/library_pthread.js Resolved
Comment thread src/settings.js Resolved
Base automatically changed from master to main March 8, 2021 23:50
@RReverser

Copy link
Copy Markdown
Collaborator Author

Few updates:

  • Switched from ASSERTIONS to 3 modes of PTHREAD_POOL_SIZE_STRICT as per description & discussion above (0 - no warnings, 1 - warn on pool exhaustion (default), 2 - strict error on trying to create one too many threads).
  • Changed throw to instead return EAGAIN from PTHREAD_POOL_SIZE_STRICT check to allow C / C++ to gracefully handle failures.
  • Added two tests for regular pthread_create as well as pthread-in-pthread creation to make sure that both fail gracefully when pool size is too low in strict mode, and pass otherwise.

@RReverser

Copy link
Copy Markdown
Collaborator Author

@sbc100 So which name do we settle on in the end? I think that's the only bit left.

@sbc100

sbc100 commented Mar 9, 2021

Copy link
Copy Markdown
Collaborator

I don't have a strong preference for an alternative name.

lgtm % another round of nits/comments.

@RReverser

Copy link
Copy Markdown
Collaborator Author

Looking at CI errors, those seem odd / unrelated? E.g.:

AssertionError: JS subprocess failed (/root/.jsvu/v8 --wasm-staging --experimental-wasm-simd test_wasm_intrinsics_simd.js --no-wasm-async-compilation --): 1.  Output:
test_wasm_intrinsics_simd.js:1469: RuntimeError: abort(CompileError: WebAssembly.instantiate(): Compiling function #119:"_Z14i8x16_any_trueDv4_i" failed: local.set[0] expected type i32, found i8x16.popcnt of type s128 @+16838) at Error
    at jsStackTrace (test_wasm_intrinsics_simd.js:1750:19)
    at stackTrace (test_wasm_intrinsics_simd.js:1767:16)
    at abort (test_wasm_intrinsics_simd.js:1463:44)
    at test_wasm_intrinsics_simd.js:1655:7
  var e = new WebAssembly.RuntimeError(what);
          ^
RuntimeError: abort(CompileError: WebAssembly.instantiate(): Compiling function #119:"_Z14i8x16_any_trueDv4_i" failed: local.set[0] expected type i32, found i8x16.popcnt of type s128 @+16838) at Error
    at jsStackTrace (test_wasm_intrinsics_simd.js:1750:19)
    at stackTrace (test_wasm_intrinsics_simd.js:1767:16)
    at abort (test_wasm_intrinsics_simd.js:1463:44)
    at test_wasm_intrinsics_simd.js:1655:7
    at abort (test_wasm_intrinsics_simd.js:1469:11)
    at test_wasm_intrinsics_simd.js:1655:7

@RReverser

Copy link
Copy Markdown
Collaborator Author

Oh yeah I see main branch is failing too.

@sbc100

sbc100 commented Mar 9, 2021

Copy link
Copy Markdown
Collaborator

Those simd tests are sometimes fragile to v8 and binaryen changes. @tlively normally knows what is going on. Certainly not related to this PR.

@RReverser

Copy link
Copy Markdown
Collaborator Author

SGTM. Looking forward to comments.

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oops.. sorry I forgot to post these comments.

Comment thread src/library_pthread.js Resolved
Comment thread src/library_pthread.js Resolved
Comment thread src/library_pthread.js Resolved
Comment thread src/settings.js Resolved
Comment thread src/settings.js Resolved
Comment thread src/settings.js Resolved
Comment thread tests/test_browser.py Resolved
@tlively

tlively commented Mar 9, 2021

Copy link
Copy Markdown
Member

Merging main should pull in #13610 and fix the SIMD tests.

@RReverser
RReverser force-pushed the thread-pool-exhaustion branch from fcd3882 to ca6ef14 Compare March 9, 2021 19:50
@RReverser

Copy link
Copy Markdown
Collaborator Author

@sbc100 Applied suggestions and answered to questions above.

@sbc100 sbc100 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm, but maybe you want to wait for #13631 to land so you can remove the EM_ASSERT thing?

Instead of throwing an error on JS side, this will now return EAGAIN code from `pthread_create` upon thread exhaustion, allowing C / C++ to gracefully handle this case.

Also adding a test for regular pthread_create as well as pthread-in-pthread creation to make sure that both fail gracefully when pool size is exceeded in strict mode, and pass otherwise.
Thanks to #13631, we can now test against plain assert messages.
@RReverser
RReverser force-pushed the thread-pool-exhaustion branch from d5f35b1 to 8819b90 Compare March 11, 2021 20:01
@RReverser

Copy link
Copy Markdown
Collaborator Author

#13631 has now landed so you should be able to remove the EM_ASSERT stuff (I think)

Yup, on it right now :)

Updated & rebased.

@sbc100
sbc100 merged commit 0589ed2 into main Mar 11, 2021
@sbc100
sbc100 deleted the thread-pool-exhaustion branch March 11, 2021 20:53
RReverser added a commit that referenced this pull request Mar 12, 2021
A minor follow-up to #13591: during the changes after opening the initial PR, I left the long warning in code even in `-s ASSERTIONS=0` / optimized builds.

That's not what we want for code size reasons, so fixing it up.
RReverser added a commit that referenced this pull request Mar 12, 2021
A minor follow-up to #13591: during the changes after opening the initial PR, I left the long warning in code even in `-s ASSERTIONS=0` / optimized builds.

That's not what we want for code size reasons, so fixing it up.
@juj

juj commented Mar 15, 2021

Copy link
Copy Markdown
Collaborator

An issue with the way this code landed is that it will now print an error message in the console for all users who pthread_create() a thread and there is no worker in the pool to do that. That used to be a perfectly fine use case, but now it is an error..

It is not at all the case that all users would need to synchronously pthread_join() or mutex-lock on a thread, and those users do benefit from a faster application startup time when they do not pause the startup to wait to prepopulate a worker pool; and less memory usage if they do not know what the pool size they need would even be. (Worker pools can take up a lot of memory and time to spin up) Many threading patterns do not require synchronous waits on the created threads (e.g. job pools). But now those users will start getting error messages as well.

In the absence of a greater redesign, PTHREAD_POOL_SIZE_STRICT == 2 is a nice feature, but PTHREAD_POOL_SIZE_STRICT == 1 is not that nice because of the above.

Given that this introduced a new -s variable, and if we do want to ultimately go ahead with #13591 (comment) , we would be looking to introduce another, and deprecate the first one. That will introduce awkward shuffling on linker vars.

Though maybe that will be unavoidable, I don't unfortunately have a chance from my employer to start working on #13591 (comment) either.

@RReverser

RReverser commented Mar 15, 2021 •

Copy link
Copy Markdown
Collaborator Author

that it will now print an error message in the console for all users who pthread_create() a thread and there is no worker in the pool to do that. That used to be a perfectly fine use case, but now it is an error..

It can be intentionally disabled via -s PTHREAD_POOL_SIZE_STRICT=0. While it's true there are cases where it's possible to safely create threads even when pool is exhausted, on practice those are rare. Most beginners and advanced devs alike who are not very familiar with Emscripten get very confused when cross-compiled code that worked fine on the original system, deadlocks with no apparent explanation.

In cases like this, it's better to show a warning and let advanced users who "know what they're doing" and are sure that their code is safe and not subject to the deadlock, to opt-out from the warning.

@RReverser

Copy link
Copy Markdown
Collaborator Author

Given that this introduced a new -s variable, and if we do want to ultimately go ahead with #13591 (comment) , we would be looking to introduce another, and deprecate the first one.

I think async API is orthogonal; even if it's introduced, the strict behaviour will be still useful. But, as I mentioned above, it would be easier to discuss that API in its own dedicated issue.

@sbc100

sbc100 commented Mar 15, 2021

Copy link
Copy Markdown
Collaborator

I suggest we move any talk of long term solutions back to #11554 or #9910 (I personally like the idea I heard about creating a dedicated worker that is charge of creating pthreads which could (perhaps) allow for the main thread to synchronously start new thread).

In terms of this specific issue here I guess the question is: Is it reasonable to ask advanced users to opt into -s PTHREAD_POOL_SIZE_STRICT=0 to avoid seeing this error/warning? I tend to agree with @RReverser that this is a worth while trade off. @juj, do you think there are enough such users and opting out is too much of burden for them?

@kripken

kripken commented Mar 15, 2021

Copy link
Copy Markdown
Member

I think that we should not show warnings when not in ASSERTIONS mode - I though that was the agreed plan but it looks like maybe not? Things were improved in #13646 but I think we should not even show a short warning in a build without assertions enabled.

I 100% agree this is a useful mode, but it is a message for the developer, and should be shown in development builds in an opt-in manner. There should be no other setting than ASSERTIONS=0 to disable such runtime warnings.

@RReverser

RReverser commented Mar 15, 2021 •

Copy link
Copy Markdown
Collaborator Author

I think that we should not show warnings when not in ASSERTIONS mode - I though that was the agreed plan but it looks like maybe not?

It was the original plan and original change in the PR, but as I said in the description, I think those should be untied from each other, and @sbc100 agreed: #13591 (comment).

That is, those warnings are orthogonal to general assertions in that you might want to disable only pthread warning (because you know your code is fine regarding deadlocks) but keep ASSERTIONS enable, or you might want to leave pthread warning for prod builds to make issues more easily discoverable (like the original issue in Squoosh that prompted me making this PR), while disabling the regular ASSERTIONS.

There should be no other setting than ASSERTIONS=0 to disable such runtime warnings.

More generally, I think it would be great to have more fine-tuned warning configuration, like any compiler/linter allows you to, but that'd be a bigger project. For now this setting is already different enough (and big enough of a production hazard) to warrant its own config IMO.

@RReverser

Copy link
Copy Markdown
Collaborator Author

Is it reasonable to ask advanced users to opt into -s PTHREAD_POOL_SIZE_STRICT=0 to avoid seeing this error/warning? I tend to agree with @RReverser that this is a worth while trade off. @juj, do you think there are enough such users and opting out is too much of burden for them?

Just to clarify my reasoning: most of the usecases I've been seeing so far are either 1) creating their own threadpools, spawning tasks onto those and blocking until those are ready or 2) create one-off threads, execute some other code on the main thread, and finally pthread_join the side thread to get results. Both of those block in production without any explanation today.

I'm sure there are advanced use-cases where users either spawn & discard threads, letting them run in background and eventually finish, or return to the event pool, but those seem like minority and can still easily opt-out from the warning after upgrade.

The tradeoff between those two categories seems worth it, worst case the latter just get an unnecessary warning that can be immediately disabled, but at least this way we don't have any users for whom Emscripten thread model seems immediately (or, worse, randomly) broken.

@kripken

kripken commented Mar 15, 2021 •

Copy link
Copy Markdown
Member

I'm not opposed to fine-grained settings for warnings. That makes sense in general and I'm not opposed to it here.

But I don't think any runtime warning messages should be enabled by default (edit: in optimized builds). Otherwise users that want a release build with no runtime warnings - the most common use case - need to start accumulating an increasingly-long list of flags to disable them.

@RReverser

Copy link
Copy Markdown
Collaborator Author

need to start accumulating an increasingly-long list of flags to disable them

I understand your reasoning. Personally given the severity of this issue + how common it is, I would go with this option flipped all the way to a strict error by default, with an opt-out for advanced users.

However, that would be a significant breaking change and I thought at least a warning that shows up before a potential deadlock even in release builds would be a suitable middle ground compromise.

After all, it's not breaking anyone and doesn't cost almost anything - the warning is very tiny when ASSERTIONS=0 and won't affect compressed size nor performance in any noticeable way - yet still provides a helpful message when things go wrong.

However, if you think that's not enough and too disrupting, I guess it's okay to disable it in release builds by default too while keeping settings separate / fine-grained.

@juj

juj commented Mar 16, 2021

Copy link
Copy Markdown
Collaborator

The tradeoff between those two categories seems worth it, worst case the latter just get an unnecessary warning that can be immediately disabled, but at least this way we don't have any users for whom Emscripten thread model seems immediately (or, worse, randomly) broken.

I don't think this error message helps reduce, but rather the opposite, I believe it will increase the number of users who think that the threading model is immediately broken. While previously users could get a deadlock, which I agree is bad, now all users will get an error, which can all the same lead them to think it is broken.

at least a warning that shows up before a potential deadlock even in release builds would be a suitable middle ground compromise.

Currently the log does not print a warning, but an error (it uses err() and not a console.warn()).

Both of those block in production without any explanation today.

I think we should attack the root causes of the block, and not thread creation itself, that can have false positives. How about instead
a) given that we do not have the resources to implement #13591 (comment), keep supporting the build mode PTHREAD_POOL_SIZE_STRICT==2 to enable pthread_create to fail if there are no workers in the pool,
b) if one pthread_joins on the main browser thread on a thread that has not been able to start, we should abort execution by printing an error. ("worker cannot start while main thread is blocked waiting on the thread to finish.")
c) whenever a new worker is created, a new pendingWorkerSpawns counter on the main thread is incremented by one. when that worker actually finishes loading, it sends a message back to main thread to decrement pendingWorkerSpawns. Then. if one pthread_mutex_lock()s or uses some other blocking wait function on a pthread_ sync primitive on the main thread, and >5 (>10?) seconds have elapsed and pendingWorkerSpawns > 0, we abort the wait and error out with a message "worker cannot start while main thread is blocked waiting on the thread to operate." or something like that.

I believe that should detect the practical deadlocks that this issue can cause.

I personally like the idea I heard about creating a dedicated worker that is charge of creating pthreads

That would change the topology of all created Workers, and require nested Worker support, which has complications and will prevent users from postMessageing anything, we'll need MessagePorts instead. Also even though Chrome finally added support for nested Workers, WebKit does not have that yet: https://bugs.webkit.org/show_bug.cgi?id=22723.

@RReverser

Copy link
Copy Markdown
Collaborator Author

I don't think this error message helps reduce, but rather the opposite, I believe it will increase the number of users who think that the threading model is immediately broken. While previously users could get a deadlock, which I agree is bad, now all users will get an error, which can all the same lead them to think it is broken.

I stongly disagree, good error messages and feedback from tooling only improve development experience over silently failing to work.

Also you're saying "all users" - but it's not all users, the warning is printed only when the pool is exhausted, which affects only 1) beginners who are not yet aware of the PTHREAD_POOL_SIZE and PROXY_TO_PTHREAD options, and previously would be surprised that their app is immediately stuck after compilation (because PTHREAD_POOL_SIZE==0) and 2) users with advanced scenarios who already can avoid the deadlock, and can certainly disable the warning.

It won't affect majority of existing Emscripten projects out there that already work with the Emscripten's threading model, that is where PTHREAD_POOL_SIZE is already preconfigured to a reasonable amount or PROXY_TO_PTHREAD is used.

Currently the log does not print a warning, but an error (it uses err() and not a console.warn()).

I don't mind changing if the output formatting is a concern, this one was just shorter and either way it's just printed to the console and not thrown as an actual error anyway (the app is not aborted in the warning mode, which is what matters for backward compat).

Regarding the other suggestions to improve DX further - please, let's move them to dedicated issues. It's a bit hard to keep track of other discussions on a closed PR :)

@kripken

kripken commented Mar 16, 2021

Copy link
Copy Markdown
Member

After all, it's not breaking anyone and doesn't cost almost anything - the warning is very tiny when ASSERTIONS=0 and won't affect compressed size nor performance in any noticeable way - yet still provides a helpful message when things go wrong.

However, if you think that's not enough and too disrupting, I guess it's okay to disable it in release builds by default too while keeping settings separate / fine-grained.

I get your reasoning, but I do feel strongly here. We have lots of other important warnings, and we don't want to show any of them in a release build by default. It's very surprising for a developer to open the web console and see a developer warning there in a release build.

@kripken

kripken commented Mar 18, 2021

Copy link
Copy Markdown
Member

ping @RReverser - this will block our next release, so it would be good to resolve. The only urgent thing is to stop showing the new assertion by default.

If you strongly disagree let's keep discussing.

If you are ok with that change but don't have time to make a PR I can make one.

@RReverser

Copy link
Copy Markdown
Collaborator Author

If you are ok with that change but don't have time to make a PR I can make one.

Yeah as I said above I'm okay with that given your reasoning, but couldn't get around to it - got a bit swamped in the last few days. If you can make it, that would be great, thanks!

kripken added a commit that referenced this pull request Mar 18, 2021
kripken added a commit that referenced this pull request Mar 19, 2021
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.

Find a way to inform users about "pthreads don't start while main is blocked" issue

5 participants