meteor-devtools-evolved icon indicating copy to clipboard operation
meteor-devtools-evolved copied to clipboard

Performance Issues

Open mitsol opened this issue 2 years ago • 18 comments

Hi! Recently i recognized that my Meteor projects got very slow using chrome (in development). At first I thought it was caused by a Meteor update, however when i tried to start chrome without extensions all went back to rocket speed! Disabling one extension after the other revealed that the meteor-devtools were the reason for this. Any suggestions how to avoid this? All in all i really like meteor-devtools 👍

mitsol avatar Apr 20 '22 07:04 mitsol

Can you share your computer specs (CPU, memory, OS, etc)? I suspect it might be related to the new performance feature capturing every minimongo call or the new Chrome's API. Please share all information you can so it helps with the investigation. Thanks :wink:

leonardoventurini avatar Apr 20 '22 12:04 leonardoventurini

Thank you for you work. I have the same issue on my MacBook Pro (16-inch, 2019):

  • 2,3 GHz Intel Core i9 8 core
  • 16 GB 2667 MHz DDR4
  • macOS Monterey 12.3.1
  • Chrome version 100.0.4896.88 (Build ufficiale) (x86_64)

plb666 avatar Apr 21 '22 12:04 plb666

I use it on an IMAC Pro 2017

  • 3,2 GHz 8-Core Intel Xeon W
  • 32 GB 2666 MHz DDR4
  • macOS Monterey 12.3.1
  • Version 100.0.4896.127

mitsol avatar Apr 23 '22 08:04 mitsol

Same here on a Mac M1 Max with 32gb. The admin console of our app is does not finish loading anymore. I agree, there are way too much subscribes on this page but still ;-)

HoptimizeME avatar Apr 29 '22 15:04 HoptimizeME

@HoptimizeME I am sad to hear these reports, I am investigating. Thanks for the feedback.

leonardoventurini avatar May 01 '22 13:05 leonardoventurini

@HoptimizeME I am sad to hear these reports, I am investigating. Thanks for the feedback.

Thanks a lot Leonardo! It's greatly appreciated. We've just discovered it and we're impressed by how much it's going to help us!

Thanks again!

HoptimizeME avatar May 02 '22 14:05 HoptimizeME

Glad to hear that @HoptimizeME.

I suspect it is some edge case specific to your applications, will need your help solving this.

@mitsol @plb666 Do you guys get any unusual amount of calls (or increased processing time) in the Performance tab for any operations when the slowdown occur?

@HoptimizeME Do you get any errors in the console? You can also go to the chrome://extensions page and inspect the extension worker:

image

leonardoventurini avatar May 02 '22 16:05 leonardoventurini

In our case, the methods and subscriptions can return fairly large JSONs. I noticed that when the page is loaded, the DDP TAB finishes displaying the information very late, in my case it takes more than a minute with this data:

image

From a quick performance analysis, it seems that all the time is used by the processTraces function.

plb666 avatar May 03 '22 09:05 plb666

Wait, processTraces is from the old devtools not mine:

image

Are you guys using this one?

https://chrome.google.com/webstore/detail/meteor-devtools-evolved/ibniinmoafhgbifjojidlagmggecmpgf?hl=en

cc @plb666 @mitsol

leonardoventurini avatar May 03 '22 16:05 leonardoventurini

Wait, processTraces is from the old devtools not mine:

image

Are you guys using this one?

https://chrome.google.com/webstore/detail/meteor-devtools-evolved/ibniinmoafhgbifjojidlagmggecmpgf?hl=en

cc @plb666 @mitsol

Hi,

Chrome says it's using this one yes. When clicking the link, the button says "Remove from Chrome" but it also says : Offered by leonardoventurini Version 1.5 Updated April 13, 2022

So it seems it's made by you. Is it confusing both because of the name or an ID ?

Regards,

Burni

HoptimizeME avatar May 03 '22 17:05 HoptimizeME

@plb666 What about you? Can you confirm that?

@HoptimizeME Nah I was just confused since @plb666 mentioned a function not present in my codebase.

If you guys want to pick a time in my Calendly so we can repro together, that would be helpful. :wink:

leonardoventurini avatar May 03 '22 20:05 leonardoventurini

@leonardoventurini I reinstalled the extension, now I have the 1.5 version of Meteor Devtools Evolved

image

The performance TAB is always empty and app performance is very slow.

Minimongo:

image

Subscriptions:

image

DDP:

image The chrome instance uses 222% of the cpu: image

Processing of DDP messages seems very slow, as does adding records to Minimongo. Whereas the profiler seems to report nothing interesting.

plb666 avatar May 04 '22 08:05 plb666

@mitsol @plb666 I see now, I believe it is the version of Chrome, it presented this kind of behavior you are describing with Manifest v3 extensions in v100. Please try upgrading if possible. If the issue still occurs then please schedule a time with me in my Calendly.

https://calendly.com/leonardoventurini/quick-call

leonardoventurini avatar May 04 '22 14:05 leonardoventurini

Got the MacBook Pro 2020 2,3 GHz Quad-Core Intel Core i7 32 GB 3733 MHz LPDDR4

Just wanted to add, that i got the same performance problems. Got even a total stuck when this extensions is activated. Tested it in Chrome version 104.0.5112.101 and Firefox 103.0.2 (64-Bit) . Everytime same result. If my subscriptions are small everything works fine, but it seem at a specific threshold the perfomance go south. Couldn't find this threshold so far.

JD2k avatar Aug 25 '22 14:08 JD2k

I am having a similar issue in my application. I am sending a few hundred records through a subscription. Each record is approximately 15 to 20 kb. When meteor devtools are enabled, the ddp is super slow to report, and the render performance in my app tanks. Disabling the dev tools totally fixes it. Additionally, I am using the added and changed functions rather than returning cursors from my publish function.

Edit: When I inspected my code, the publish function ran in an acceptable amount of time, about a second or so. The data showed up in minimongo in a reasonable amount of time (maybe 10 seconds or so), but definitely slower than when devtools were disabled. Upon profiling, a lot of the time seemed to be taken up by the useSubscription react hook.

My system is windows with a 12th gen i7 and 16gb of RAM. Most recent version of chrome.

dallman2 avatar Apr 20 '23 05:04 dallman2

@dallman2 Can you share an anonymized version of the publication's code so we can repro? And the Meteor version too. Thanks!

leonardoventurini avatar Apr 20 '23 09:04 leonardoventurini

@dallman2 Can you share an anonymized version of the publication's code so we can repro? And the Meteor version too. Thanks!

@leonardoventurini , I do not think I will be able to produce an anonymous version of the publish function, there is a lot of code that backs it up. I can give you a pseudocode version, though. Also we are on meteor 2.7.3

Meteor.publish('mypublish', function(queryInfo){
     if (this.userId) {
        const publisher = new PublicationHelper(this, queryInfo);
        publisher.doQuery();

        this.onStop(() => {
            // this calls `stop` on our live query handles
            publisher.destruct();
        });
    }
    this.ready();
})

Here is a basic look at what happens in doQuery:

function doQuery(){
      // do the query
      console.time('doquery');
      const cursors: Mongo.Cursor<Document, Document>[] = executeQuery();
      console.timeEnd('doquery');
      // about 0.2ms
      // set up query observers
      console.time('cursormap');
      cursors.forEach(singleCursorSetup);
      console.timeEnd('cursormap');
      // about 5s
}

You see some mapping going on here, but really, the list of cursors returned from the executeQuery function is at most two elements. Here is how the data gets sent over in singleCursorSetup:

        const obs = cursor.observeChanges({
            added(id: string, doc: Document) {
                addedHandler(target, id, doc);
            },
            changed(id: string, fields: Document) {
                changedHandler(target, id, fields);
            },
            removed(id: string) {
                removedHandler(target, id);
            },
        });

The handler methods are what eventually invoke the this.added and this.changed functions. Again, the code in the publish function is not what is taking a long time. The added and changed functions are all called within a few seconds (~5) for a result set of about 300 documents. Upon inspection of the front end, a lot of time is spent in the useSubscribe method.

Edit

I just remembered that my application is using a non-default mongo driver. That is, the collections that I'm trying to pull from reside in a different meteor project. Thought that might be good intel to have...

dallman2 avatar Apr 20 '23 19:04 dallman2

Hi, I also have the same performance problem, high RAM / CPU / power consumption.

fn-jenny avatar Jul 29 '23 21:07 fn-jenny