tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

TinyGo Wasm keeps freezing or stop working on processing thousands of data

Open fenezema opened this issue 4 years ago • 3 comments

Hello, Currently, I'm facing this issue when loading data to memory.

I load data from browser localStorage. And because of the nature of browser localStorage can only store string data, there are a lot of repeated process of decode these data and map these data to struct. At some point, during those loop, I will find 2 - 3 data taking for about 3 - 5 seconds each to finish while the others only take less than 20ms to map. And no error appears on the browser console as well during this process.

The number of data I load is about 2000-3000 data. But it's not a problem if the number of data only around 100-200 data. And it seems that it works just fine if I compile this with Go regardless the number of data I use.

I've been trying to figure things out for some days now, and has not been able to solve this problem. I also have no clue if this is a memory issue or something else. I also did try to solve this by not loading the data to memory, but it seems it's still happening for some reason.

Any information regarding this issue is very much appreciated. Thank you

TinyGo version: tinygo version 0.18.0 linux/amd64 (using go version go1.16.5 and LLVM version 11.0.0)

fenezema avatar Aug 06 '21 03:08 fenezema

@fenezema it is hard to determine what the issue is except possibly garbage collection backup. If you are past this issue, please close this issue. Otherwise, it would be easier to troubleshoot if you had a Github repository to share which can reproduce the problem.

codefromthecrypt avatar Sep 07 '22 08:09 codefromthecrypt

I suspect this is a performance cliff in the garbage collector. I tried to fix it in #2880 but it doesn't work as expected. I still need to figure out why that PR fails.

aykevl avatar Sep 15 '22 14:09 aykevl

I agree it's probably related to the garbage collector. Do you have some sample code we could play with?

dgryski avatar Sep 15 '22 19:09 dgryski

Closing for now. There have been improvements in the garbage collector. If you're still encountering errors, please provide a test case for us to debug with.

dgryski avatar Feb 02 '23 01:02 dgryski