How to improve startup performance?

Having problems with building or using the CefGlue .NET/Mono binding? Ask your questions here.

Moderator: fddima

How to improve startup performance?

Postby uwekeim » Thu Jun 13, 2013 10:09 am

In my own application I do experience the same behavior as in CefGlue.Demo.WinForms:

When the application starts and the first CEF browser is being "opened", it takes about 2-3 seconds in multi process mode until the content is being shown/loaded. The next browsers that are opened in the same window/tab are way faster, only approx. less than a second.

In (the unsupported) single process mode even the first browser on application startup is really fast.

So I assume the this might be related to the fact the the render process application is also a .NET application.

I've fired up ANTS Performance Profiler on the CefGlue application and it seems to me that in fact the startup of the new process for the first time is the bottleneck:

Image
Full resolution

Starting the second tab only seems to take half of the time:

Image
Full resolution

I've also recorded a short screencast to (hopefully) demonstrate the effect.

My goal is to improve the first time startup, if possible. I would assume if I'm using a unmanaged application instead of a managed one, the startup performance would be way better.

So my questions are:

- Is my assumption right, that the render process startup causes this delay?
- Is there anything I can to improve?

(Side note: I would have loved to see a native CEF example to compare with but unfortunately it seems that none exists and the only one I found does use CEF 1, not 3 - am I wrong here?)
Last edited by uwekeim on Thu Jun 13, 2013 12:10 pm, edited 1 time in total.
User avatar
uwekeim
Techie
 
Posts: 17
Joined: Wed Jun 05, 2013 12:34 pm

Re: How to improve startup performance?

Postby fddima » Thu Jun 13, 2013 12:03 pm

Hi.

Thanks, for detailed explanation.

1) In general it is good idea test same with cefclient (native sample application, it is exists, it can be easily built from sources, check binary package more accurately).

2) .NET-related startup questions probably you can solve by using ngen. But i'm not sure that it will be significant difference in this case. Also .NET 4.5 do this automatically, so theoretically running same time when it is 'cached' will be fast without explicit ngen. Personally i have relative slow first run (cold start), and always have relative fast hot run (i.e. second running of application, as at your's video).

3) Did you use proxy autodetection? This is also can provide additional delays.

4) If you did not use custom features of renderer (i mean did not implement CefRenderProcessHandler) - you can use native renderer. Or write own native renderer executable. It will add some speed-up.

In general i'm doesn't see situation, as at your's video. I'm bet on proxy auto detection (auto discovery), but i'm can wrong, of course.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to improve startup performance?

Postby uwekeim » Thu Jun 13, 2013 12:21 pm

Rgd. 1.) Just found it, thanks for point out! Takes the same startup time as my managed application. Shocking!

Rgd. 2.) The NGEN thing didn't help anything; I already tried that.

Rgd. 3.) The proxy thing is unclear to me; I searched through all CEF sources as well as through all CefGlue sources. Found nothing. Could you give me some hints, please?
User avatar
uwekeim
Techie
 
Posts: 17
Joined: Wed Jun 05, 2013 12:34 pm

Re: How to improve startup performance?

Postby fddima » Thu Jun 13, 2013 12:38 pm

uwekeim wrote:Rgd. 3.) The proxy thing is unclear to me; I searched through all CEF sources as well as through all CefGlue sources. Found nothing. Could you give me some hints, please?

Did you have proxy? You are use proxy? In internet settings (in windows control panel) it is enabled option 'automatically detect settings'? may be you network uses WPAD (web-proxy auto discovery)? You can also enable full log in cefsettings (verbsole) and try look on something interesting in it...

PS: What hardware?
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to improve startup performance?

Postby uwekeim » Thu Jun 13, 2013 12:49 pm

Disabling the "Auto detect" proxy settings in the Internet Options really improved it by 1-2 seconds! (I'm having no proxy on my PC nor in our company network).

Is there any chance to disable/postpone/control the proxy lookup thing in CEF for my local application only?

Regarding the hardware: Two month old monster machine ;-) with 16 GB RAM, 500 GB SSD and a fast i7-3770 CPU. So this should hopefully have no negative impact.
User avatar
uwekeim
Techie
 
Posts: 17
Joined: Wed Jun 05, 2013 12:34 pm

Re: How to improve startup performance?

Postby uwekeim » Thu Jun 13, 2013 1:40 pm

What I've now done, as a first start, is to programmatically disable the proxy:

Code: Select all
internal static class ChromiumCommandLineHelper
{
    public static void AdjustCommandLine(CefCommandLine commandLine)
    {
        // Added because of slow startup. Check to see whether to make configurable or whether
        // to create bypass list.
        //
        // See http://peter.sh/experiments/chromium-command-line-switches/#no-proxy-server for meaning.
        // See http://magpcss.org/ceforum/viewtopic.php?f=14&t=10760 for background.
       
        commandLine.AppendSwitch(@"no-proxy-server");
    }
}

I call this function my overrides of

  • CefApp.OnBeforeCommandLineProcessing
  • CefBrowserProcessHandler.OnBeforeChildProcessLaunch
Probably I have to put still lots of more intelligence into it.
User avatar
uwekeim
Techie
 
Posts: 17
Joined: Wed Jun 05, 2013 12:34 pm

Re: How to improve startup performance?

Postby fddima » Fri Jun 14, 2013 2:34 am

CefApp.OnBeforeCommandLineProcessing must be enough to disable proxy (only main (browser) process perform all IO, and renderer process never do any IO).
CEF follow's system proxy settings, if it is not specified explicitly. So your's problem is incorrect system proxy configuration, and probably you don't needed disable proxy explicitedly in your's code (it's your's decision).

PS: Delay with proxy autodetection can be caused 'cause in fact it works with DHCP, and if it is replied with wpad url - it will fetch url and execute it (in separate helper process, as i know). Probably in your's network something configured, but not completely / incorrectly and something goes wrong. Or nothing configured, and CEF wait's DHCP reply but doesn't got it, and then fallback to working without proxy. It is only my assumptions, not facts.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to improve startup performance?

Postby uwekeim » Fri Jun 14, 2013 9:42 am

Just found out that it also helps to use the "winhttp-proxy-resolver" switch to improve startup performance instead of disabling the proxy altogether.
User avatar
uwekeim
Techie
 
Posts: 17
Joined: Wed Jun 05, 2013 12:34 pm

Re: How to improve startup performance?

Postby fddima » Fri Jun 14, 2013 10:03 am

uwekeim wrote:Just found out that it also helps to use the "winhttp-proxy-resolver" switch to improve startup performance instead of disabling the proxy altogether.

Thanks. Looks useful.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to improve startup performance?

Postby magreenblatt » Wed Jun 19, 2013 5:27 pm

uwekeim wrote:Just found out that it also helps to use the "winhttp-proxy-resolver" switch to improve startup performance instead of disabling the proxy altogether.

Keep in mind that resolving proxy settings is dependent on a number of network factors and can take an unknown amount of time. You should design your application to first show a static splash page and then redirect to the actual website (for example, using meta refresh -- the redirect will be blocked until proxy resolution completes). See viewtopic.php?f=6&t=10541#p16135 for related discussion.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm

Next

Return to CefGlue Forum

Who is online

Users browsing this forum: No registered users and 28 guests