Bug 6091 - [Editor Mgmt] Opening editor can trigger autobuild with no progress
Summary: [Editor Mgmt] Opening editor can trigger autobuild with no progress
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: 2.1 RC2   Edit
Assignee: Knut Radloff CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 2505 6925 (view as bug list)
Depends on: 28384
Blocks:
  Show dependency tree
 
Reported: 2001-11-20 03:37 EST by Erich Gamma CLA
Modified: 2003-03-06 19:06 EST (History)
6 users (show)

See Also:


Attachments
Workbench.java (57.33 KB, text/plain)
2003-03-06 18:17 EST, Knut Radloff CLA
no flags Details
messages.properties (73.38 KB, text/plain)
2003-03-06 18:18 EST, Knut Radloff CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Gamma CLA 2001-11-20 03:37:08 EST
By convention opening an editor does a refreshFromLocal. This can trigger an 
autobuild as a side effect. I had a workspace that was not built and and 
autobuild got triggered when opening the first editor. Since there is no 
progress the workbench was not responsive during around 10 minutes.
Comment 1 Erich Gamma CLA 2001-12-14 05:34:20 EST
*** Bug 6925 has been marked as a duplicate of this bug. ***
Comment 2 Nick Edgar CLA 2001-12-20 09:37:42 EST
This is in FileDocumentProvider.createElementInfo.
Is there any way around this?
Comment 3 Kai-Uwe Maetzel CLA 2002-02-06 05:31:11 EST
Removing the "refreshFromLocal" call from the code editor opening sequence 
raises another major usability concern. (Out of sync notification when opening 
an editor.) Would it be possible for the Workbench to switch autobuild off when 
restoring previous state? JDT, e.g., disables autobuild for serveral of its 
compound actions to make it run only once rather than multiple times.
Comment 4 Kai-Uwe Maetzel CLA 2002-09-12 11:59:36 EDT
Moving to Platform UI for comment.
Comment 5 Eduardo Pereira CLA 2002-11-22 12:55:43 EST
*** Bug 2505 has been marked as a duplicate of this bug. ***
Comment 6 Eduardo Pereira CLA 2002-11-25 12:26:56 EST
- The autobuild will happen when the first editor is opened which may not be at 
startup.
- There are some places in the workbench that we do not do a refreshFromLocal 
for free, like in the import and export. 
- If we turn autobuild off/on in the startup. Would it have to verify if the 
workspace is built when switching it on? Would it make that startup slower?

Whenever a editor is opened, could we check if it is out-of-sync and open a 
dialog asking the user if we should refresh and then open a progress bar?

Moving to Text for comment.
Comment 7 Kai-Uwe Maetzel CLA 2002-12-11 11:20:23 EST
I added (experimental - for now -) code to AbstarctTextEditor that wraps the 
the init method of the editor part into a IRunnableWithContext and runs it in 
the context of the ApplicationWindow. This way at least progress is shown on 
auto build. The user knows what happens. Asking the user whether they want to 
refresh is not a valid alternative as if the user turns it down we'll 
immediately end up with CoreExceptions. I.e. the editor would not be opened.

This does not solve the problem when restoring the editor in start up. If the 
editor is the front most editor and its input changed externally, the 
refreshFromLocal call triggers an auto build without any progress. This issue 
is still to be solved. I don't see how the editor itself could solve this 
without workbench involvement.

I think any necessary autobuild should only happen after the workbench UI has 
been restored, so that the user sees the progress information.

Moving to Platform UI.
Comment 8 Nick Edgar CLA 2002-12-11 11:39:13 EST
Core currently does the autobuild when you refresh.  The Workbench could turn 
off auto-build when restoring workbench state, then restore it after the UI has 
been restored, and provide a progress monitor.

DJ, do you see any risk in doing this?
Comment 9 DJ Houghton CLA 2002-12-11 13:06:59 EST
We don't encourage people to turn off auto-build for their own purposes and 
then setting it back on.

Would calling IResource.isSynchronized(depth) and only call #refreshLocal when 
the resource is out of sync suit your needs?
Comment 10 Nick Edgar CLA 2002-12-15 22:01:55 EST
Checkin isSynchronized first should not be any different than calling refresh 
directly.  In the external modification case, you still need to do the refresh
which will still trigger an autobuild.  
Also, I would imagine that refreshLocal should do this internally anyway, and 
not trigger a build if the file is already in sync.

If we go ahead and turn off autobuild during workbench restore, what ill 
effects can happen?
Comment 11 John Arthorne CLA 2002-12-16 10:20:33 EST
From a technical point of view I don't see a problem with turning off autobuild
during startup, and then turning it back on once you've got enough UI to display
a progress bar.  Turning autobuild back on will *not* automatically trigger a
build, so the next operation to run will get the build.  I would recommend
turning on autobuild from within an IWorkspaceRunnable so that the build is
forced right away.
Comment 12 Nick Edgar CLA 2002-12-16 10:38:23 EST
We will do this for M5.
To clarify: IWorkspace.run always triggers an autobuild if on, even if the body 
of the runnable does nothing?
Comment 13 John Arthorne CLA 2002-12-16 11:19:21 EST
Good thing I double-checked.  It should cause a build, but it currently doesn't.
 Opened bug 28384 for this, targetting M5.
Comment 14 Eduardo Pereira CLA 2002-12-16 11:25:58 EST
So, we are going to pay the price of one build on startup even when nothing 
was changed externally.
Comment 15 John Arthorne CLA 2002-12-16 11:55:35 EST
Eduardo makes a good point -- this change would cause a slightly higher build
overhead.  To quickly explain, our current optimization is that if autobuild is
on, and the current workspace tree is unchanged, then we skip the build.  This
is incorrect if autobuild has just been turned on.  In this case, we require a
more complex check to see if anything has changed since the last incremental
build.  Since each builder may have been invoked manually during the interval
when autobuild was turned off, this check has to be done for each individual
builder on every project.  This isn't a huge cost, but it would incur a hit over
the current startup cost.  To give a feel for this cost, this is the same
overhead you get when a single file is modified when autobuild is turned on.
Comment 16 Nick Edgar CLA 2003-03-05 21:16:19 EST
Knut, can you grease this in for RC2?
Comment 17 Knut Radloff CLA 2003-03-06 17:53:55 EST
With my test workspace (org.eclipse.ui plugins loaded as source and prereqs 
loaded as binaries), delaying the auto-build and running it in a 
IWorkspaceRunnable (WorkspaceModifyOperation actually) costs about 5% over the 
time of the usual workbench restore.
The average workbench restore with my test workspace is 13100ms without 
deferring the build and 13800ms with.
These numbers are from a scenario using ProgressMonitorDialog for progress. 

The dialog popping up and doing nothing (in the normal use case without 
external changes) is annoying. I remember seeing somewhere how to tell it to 
not show if the operation is short running. I just can't remember where I saw 
that.
I'll also try using the workbench window for progress. However, a dialog may be 
better since the build is part of workbench startup.

I'll attach code, soon for Eduardo or Nick to review and release.
Comment 18 Knut Radloff CLA 2003-03-06 18:17:01 EST
Created attachment 3892 [details]
Workbench.java

Workbench.java based on version 1.59 (current HEAD state)
Comment 19 Knut Radloff CLA 2003-03-06 18:18:21 EST
Created attachment 3893 [details]
messages.properties

messages.properties based on version 1.96
Two new strings:
Workbench.autoBuild = Building...
Workbench.problemAutoBuild = Problem occurred while building workspace.
Comment 20 Knut Radloff CLA 2003-03-06 18:21:16 EST
I realized that it's the status line progress indicator that is delayed.
The attached code uses the active workbench window and falls back to using a 
progress dialog if there is no active workbench window.
Using the status line instead of the progress dialog cuts the performance 
penalty of the fix by about 1% to under 4%.
Comment 21 Knut Radloff CLA 2003-03-06 18:57:52 EST
Nick pointed out that the attached code does not take the refresh on startup 
feature into account. This would result in two bulds when the refresh results 
in resource deltas.
We should move the refreshFromLocal followed by enableAutoBuild below the 
try/finally block. I'm not sure why we even have the try/finally block. All the 
methods inside the try block handle exceptions already.

} finally {
	UIStats.end(UIStats.RESTORE_WORKBENCH, "Workbench"); //$NON-NLS-1$
}
refreshFromLocal(commandLineArgs);
enableAutoBuild();
// Listen for auto build property change events
getPreferenceStore().addPropertyChangeListener(propertyChangeListener);


This could be more refined since the refresh opens a progress dialog and the 
enableAutoBuild uses the status line.
Comment 22 Knut Radloff CLA 2003-03-06 19:06:45 EST
Released attached changes with modifications shown above.
Fixed in >20030306