question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Opening editor takes 7 seconds

See original GitHub issue

@marcushellberg commented on Fri Aug 10 2018

Opening the editor window for the first time takes an unreasonably long time. It gives a bad impression of Vaadin in my opinion.

Of the 7 seconds, 5 are spent on the server. See attached screenshot and chrome perf recording.

screen shot 2018-08-10 at 9 52 18 am

https://transfer.sh/3jOrC/bb-open-editor.json


The issue has been originally created in beverage repo. But this is a generic performance issue with com.vaadin.flow.component.internal.ComponentMetaData.findDependencies method execution (see comments from Leif below). So this needs design and a proper solution since at the moment there is no obvious way how to solve it. We are doing everything possible at the moment: cache the result but it’s necessary to run it a least one time.


@denis-anisimov commented on Sat Aug 11 2018

Steps to reproduce?

Does it happen with an empty dialog and just calling it open method ?


@marcushellberg commented on Sun Aug 12 2018

  1. Download latest starter from vaadin.com/start
  2. Run app
  3. Click edit on any beverage

@denis-anisimov commented on Sun Aug 12 2018

OK, thanks.


@denis-anisimov commented on Wed Aug 15 2018

True, the very first time the dialog loading takes very long time. Every subsequent call of any other dialog works well.


@denis-anisimov commented on Wed Aug 15 2018

There is no any explicit performance issues on the server side when the dialog is requested being opened. All server side logic is executed right away. The problem is the dialog content: it has many components which have not been loaded anyhow previously. Here is the attached image of the resources that are loaded on dialog load request:

screen shot 2018-08-15 at 2 16 22 pm

So I guess the reason of the behavior: is the first time loading a bunch of remote resources from webjars. That’s why it doesn’t happen any subsequent time.

I don’t see what we can do in general here. May be something in this specific case preload some components which are expected to be used anyway because most likely a user will open some dialog…


@Legioth commented on Wed Aug 15 2018

The time it takes to load the HTML imports isn’t the main problem. There’s a significant time spent in the UIDL request: 2.10s now when I tested it. After a couple of repetitions to let the JVM and any of Flow’s own caches to warm up, the server-side time goes down to around 100ms on my machine. This is still quite much compared to the initial view which takes around 50ms of server-side time for both generating UIDL and producing the HTML page.

screen shot 2018-08-15 at 16 06 43


@Legioth commented on Wed Aug 15 2018

According to JProfiler, most of the time is spent in com.vaadin.flow.component.internal.ComponentMetaData.findDependencies. The result of this is cached so it only happens the first time the code is run after the application has been started.

Out of the time spent in that method, about 60% is spent in javax.servlet.ServletContext.getResourceAsStream, which basically does IO to read and unzip files from inside various webjars.


@denis-anisimov commented on Wed Aug 15 2018

Well, I was able to reduce the opening time via just adding lazy pre-load of the components.

findDependencies is more tricky since it’s needed to be called and this is the server-side time during the request. The only way how it may be reduced is creating a background thread which collects dependencies and put them into the cache before the dialog is even opened…


@Legioth commented on Wed Aug 15 2018

One approach for findDependencies might be to whitelist dependencies that we know might be encountered, but that are not necessary to parse through since we know that nothing of interest will be found through them.


@Legioth commented on Wed Aug 15 2018

To make things even more advanced, we could even automatically precompute the dependencies for each of our components and include a manifest in the .jar file.


@marcushellberg commented on Wed Aug 15 2018

@denis-anisimov’s solution is OK in the context of this demo. But ideally, we would come up with a solution where a developer doesn’t accidentally introduce this kind of slowness into their app by just using our APIs as documented.


@denis-anisimov commented on Wed Aug 15 2018

True, true.

But there are real reasons behind that behavior. So it requires a serious design in Flow to avoid such issues.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
denis-anisimovcommented, Aug 17, 2018

Agreed. OK, let’s start with that and exclude everything inside frontend://bower_components/polymer/

1reaction
Legiothcommented, Aug 17, 2018

We can be really sure that frontend://bower_components/polymer/ won’t contain anything that would be related to themes. Only blacklisting that one and nothing else would by itself improve performance by 80%.

If there are still performance problems after fixing the caching and blacklisting frontend://bower_components/polymer/, then we might evaluate whether we could somehow also blacklist (or precompute) more stuff, but until that, I don’t think any more blacklisting would be necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unreal taking a long time to open a project - Blueprint
The Editor Startup Map is the map that will be open when you're opening your project. The bigger the map, the longer it...
Read more >
Editor window startup is slow · Issue #2654 · atom/atom - GitHub
Just saying, Atom takes ~12 seconds to open an editor window on my machine. Sublime Text, in comparison, takes ~2 seconds.
Read more >
Windows Live Movie Maker only plays 7 seconds of sound ...
Windows Live Movie Maker only plays 7 seconds of sound from mp3. Hi Microsoft and Blogers: ... And it takes forever for it...
Read more >
You And Your Business Have 7 Seconds To Make A First ...
Within the first seven seconds of meeting, people will have a solid impression of who you are — and some research suggests a...
Read more >
SnagIt so insanely slow - TechSmith Support
It takes 6-7 seconds after hitting the red button or printscreen ... makes the Snagit editor open instantly after taking a screenshot.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found