Fork me on GitHub
#re-frame
<
2019-02-17
>
caleb.macdonaldblack13:02:23

I'm loading lots of data into app-db. Probably around 16mb of csv that I convert to a datastructure. I run some validation and pull up to 15 invalid rows and display them. If the number of invalid rows are less than 15, I show the remaining number of top rows. I eventually send this data to an API. The app freezes completely when I load it in (via paste on a div) which is acceptable given the size. However afterwards the app is sluggish and freezes frequently for about 30 seconds. After that everything seems fine. This freezing occurs on views where the subscription accessing the data isn't even rendered. Is there any way I can improve this? I would even consider moving the data out of the app-db and somewhere else

nenadalm14:02:22

You should first investigate what is it that takes long time. Then you should improve the part of the app that takes long.

caleb.macdonaldblack13:02:30

I'm not rendering all this data to the view ever. Only 25 small rows of it

Braden Shepherdson18:02:11

first thing to check would be the Chrome DevTools profiler, or similar. see where the time is being spent.

Braden Shepherdson18:02:31

it might be a general JS performance problem, not anything wrong with your subscriptions.

danielcompton22:02:54

@caleb.macdonaldblack if you use re-frame-10x, it will show you which subscriptions are running

danielcompton22:02:12

It sounds like there might be some subs running in places where you don't expect it

danielcompton22:02:39

Also, do you have any middleware running which are doing diffs or other potentially expensive operations?

danielcompton22:02:10

But I'd second @braden.shepherdson’s suggestion, it should be very clear what is causing a 30 second hang in devtools profiler.

danielcompton22:02:08

Protip: you can give an anonymous function a name if you provide it after fn. E.g. (fn [xy] ...) => (fn xy-handler [xy] ...), and it will show up with that name in devtools profiler

caleb.macdonaldblack22:02:53

I don't have any middleware running. And thanks for the tip, I'll take a look now and see if I can work it out.

caleb.macdonaldblack22:02:39

Wow thanks everyone. I honestly thought given the size of the data It wouldn't be possible to optimise but I can see that it its. It was a subscription causing it to slow down. I've moved that work to an event handler as https://github.com/Day8/re-frame/blob/master/docs/Solve-the-CPU-hog-problem.md suggested. I'm going to batch it now and that should fix the remaining issues.