Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326685 - Canceling compare does not work or takes way too long
Summary: Canceling compare does not work or takes way too long
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.7 M3   Edit
Assignee: Tomasz Zarna CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-30 11:08 EDT by Dani Megert CLA
Modified: 2010-10-11 10:51 EDT (History)
2 users (show)

See Also:
tomasz.zarna: review+


Attachments
patch (1.31 KB, patch)
2010-10-05 04:41 EDT, Krzysztof Kazmierczyk CLA
tomasz.zarna: iplog+
tomasz.zarna: review+
Details | Diff
files to test.zip (948.41 KB, application/zip)
2010-10-05 04:56 EDT, Krzysztof Kazmierczyk CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2010-09-30 11:08:19 EDT
I20100928-1200.

1. disable to use the capping algo
2. compare two very large files with each other (e.g.:
   /org.eclipse.jdt.ui/dictionaries/en_GB.dictionary
  /org.eclipse.jdt.ui/dictionaries/en_US.dictionary
3. in the dialog click cancel
==> I have to wait for about 6 seconds until it cancels and shows not diff. This is about the same time it would have taken without canceling but then I would have seen the diff.
Comment 1 Tomasz Zarna CLA 2010-09-30 11:56:18 EDT
Krzysztof, could you please take a look at it?
Comment 2 Krzysztof Kazmierczyk CLA 2010-09-30 12:04:45 EDT
(In reply to comment #1)
> Krzysztof, could you please take a look at it?

OK I will look at that.
Comment 3 Krzysztof Kazmierczyk CLA 2010-10-05 03:51:50 EDT
I have checked it.
The files from [1] contain only one big change which is at the end of the file.
Reaching by LCS algorithm to this change takes 0 ms. Then it takes approx 4s on my machine to find which part of the files is exactly different. Then there are no changes to the end of the file. 

The current implementation of canceling cannot stop in org.eclipse.compare.internal.core.LCS.find_middle_snake(int, int, int, int, int[][], int[]) which takes most of the time in this case.

Dani, if you try two big files with many changes or try patch from bug 324993 comment 6 you will observe, that cancel exactly stops comparing in that way, that it exactly lasts less time than waiting until it ends.

[1] /org.eclipse.jdt.ui/dictionaries/en_GB.dictionary and
  /org.eclipse.jdt.ui/dictionaries/en_US.dictionary
Comment 4 Dani Megert CLA 2010-10-05 03:54:18 EDT
> Dani, if you try two big files with many changes or try patch from bug 324993
> comment 6 you will observe, that cancel exactly stops comparing in that way,
> that it exactly lasts less time than waiting until it ends.
Just try the ones from comment 0. As a user I don't care about the implementation. If I click cancel and have to wait another 6 seconds then this is wrong.
Comment 5 Krzysztof Kazmierczyk CLA 2010-10-05 04:41:10 EDT
Created attachment 180229 [details]
patch

Here is the patch. Which solves Dani problem.
The patch allows to stop LCS algorithm in org.eclipse.compare.internal.core.LCS.find_middle_snake(int, int, int, int, int[][], int[], SubMonitor).

Tomasz, could you look at this patch?
Comment 6 Krzysztof Kazmierczyk CLA 2010-10-05 04:56:31 EDT
Created attachment 180230 [details]
files to test.zip

Here are two files on which I have tested my patch. Before applying the patch you cannot stop comparing. After applying the patch, comparing stops immediately when you hit cancel.

Just to clarify: the patch also works fine for example from comment 0.
Comment 7 Tomasz Zarna CLA 2010-10-06 04:13:07 EDT
Thanks for the patch Krzysztof, I will try to look at it this Friday.
Comment 8 Tomasz Zarna CLA 2010-10-09 05:50:27 EDT
The patch looks good, extra checking for monitor cancellation did the job. The only thing I was worried about was the fact that calling worked() for a monitor not only checks if the monitor is canceled but also adds a tick. However, playing with the patch I haven't noticed any side effects, except that now I'm able to see the progress monitor for long running computations, which is good. I added a missing param description in javadoc and applied the fix. Thanks Krzysztof.

Fixed in HEAD, available in builds >=N20101009-2000.
Comment 9 Dani Megert CLA 2010-10-11 10:51:32 EDT
Verified in N20101010-200: Cancel now happens much faster.