Replies: 3 comments 3 replies
-
Here's the stack from the crashed thread:
|
Beta Was this translation helpful? Give feedback.
-
Well, that's annoying. Just to be clear, you see this only with Safari on iOS? Safari on Mac and Firefox/Chrome on iOS are fine? I don't have an iOS device so I have very little experience with them. Your analysis looks plausible to me, except that unless there has been an Apple policy change, third-party browsers on iOS have to use Apple's browser engine instead of their own. I would think Chrome and Firefox on IOS should show the same behavior. Maybe Apple doesn't give third-party browsers access to the same optimizations? I did at one time see long WASM loading delays and crashes using Chrome on Android devices. This might have been an ARM code generation issue because I couldn't make it happen on the Android emulator. It went away in later versions without being fully investigated, but it sounded like register allocation was a contributor there as your crash stack also shows. It seems like SQLite WASM can put a lot of stress on code generators. Have you submitted a WebKit bug? If so, then please link it here. WebKit development is often frustratingly opaque but they have been quite responsive to recent bug reports I submitted for which I provided test pages that demonstrated a problem. Off the cuff ideas:
|
Beta Was this translation helpful? Give feedback.
-
Everything (Chrome, Firefox, Safari) is broken on iOS due to the fact that they're all just webkit. Only Safari is broken on OS X.
Not yet but I'll do that shortly. Example of the issue on Safari on OS X: output.webmfirst run hits 500% CPU, 400% of the CPU being taken by WebKit Threads. Next run is ~140% total CPU, WebKit threads taking 4%. |
Beta Was this translation helpful? Give feedback.
-
I think this is a Safari JIT issue rather than wa-sqlite but wanted to make you aware and see if you have thoughts on how we could move forward.
Background
Myself and others started noticing that after doing about a hundred inserts + selects, Safari starts hammering the CPU at ~300-400%
These are all inside of "WebKit" threads
Usage continues to stay high for ~30 seconds after all interactions with the database are complete. After that 30 seconds, usage begins to settle down.
Re-running the same inserts & selects again after the CPU has settled, usage is more reasonable and stays < %150. WebKit threads at this time are doing almost no work.
You can repro this by commenting out all benchmark cases except IDBBatchAtomic and running through that. I'd expect ~100% CPU while running the benchmark but not the 300, 400, sometimes almost 500%. That and I wouldn't expect usage to stay elevated after the benchmark is complete.
You can repro with any case that does a large number of inserts and selects, doesn't need to be the benchmarks and these db events can be spaced out over tens of seconds. They don't have to be going as fast as possible. I.e., cases where Firefox or Chrome never go above 10% CPU, Safari will quickly climb to 300-400%. Safari will also sometimes crash during this.
Chrome & Firefox don't have these issues.
Investigation
My theory is that the problem is caused by the safari JIT given:
The elevated CPU wouldn't be so problematic except on mobile devices where the "30 seconds" can be upwards of minutes and the fact that Safari sometimes crashes during this.
As I was writing this, one thought did come to mind. Maybe this issue doesn't happen with the non-asyncify build (or is ameliorated to some extent) given the WASM is much smaller and presumably the code is more straightforward to optimize.
Beta Was this translation helpful? Give feedback.
All reactions