Bug 182359 - [compiler] optimize line number generation using the new getLineNumber method
Summary: [compiler] optimize line number generation using the new getLineNumber method
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2007-04-13 12:52 EDT by Olivier Thomann CLA
Modified: 2007-09-18 10:44 EDT (History)
5 users (show)

See Also:


Attachments
Proposed fix (16.85 KB, patch)
2007-05-16 22:33 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (16.85 KB, patch)
2007-05-22 12:37 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix (17.42 KB, patch)
2007-05-23 14:00 EDT, Olivier Thomann CLA
no flags Details | Diff
Update previous patch for HEAD contents (17.42 KB, patch)
2007-07-30 22:36 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2007-04-13 12:52:34 EDT
We should investigate how to optimize the generation of line numbers using the new method getLineNumber(..) using a better scope for searching.
Comment 1 Olivier Thomann CLA 2007-05-16 22:33:31 EDT
Created attachment 67566 [details]
Proposed fix

This improves slightly the performance.
Frédéric will confirm the new perfs results.
Comment 2 Olivier Thomann CLA 2007-05-22 12:37:41 EDT
Created attachment 68161 [details]
Proposed fix

This patch seems to make a 1.5% improvement in some performance tests.
Comment 3 Olivier Thomann CLA 2007-05-22 12:38:52 EDT
Jérôme, Frédéric, please review.
Comment 4 Frederic Fusier CLA 2007-05-23 07:11:25 EDT
I definitely think I lack knowledge on code generation to be really efficient while reviewing this big - and I guess risky - change... Can you ask someone who already has this background to review it?
Thanks
Comment 5 Olivier Thomann CLA 2007-05-23 07:41:07 EDT
Maxime, Philippe, please review.
Comment 6 Maxime Daniel CLA 2007-05-23 10:26:26 EDT
Olivier, I'm afraid a few things look odd to me, but this may come from a lack of familiarity with that code area:
- on line 5784, I don't see how we could have length equal to 0; if it were so, we would have no line separator, hence the method would be on a single line and we would have executed line 5778 instead?
- I am not sure why you are passing this.lineNumberEnd - 1 to getLineNumber; is that to save a loop iteration? if so, this would deserve a comment.
I've not dug deeper so far, since I'd like to better understand the overall picture.
Other remarks:
- I would not initialize lineNumber when declaring it; this will let the compiler tell you if all branches initialize it properly (and 0 is not a valid value anyway - we save an assigment);
- while this is not related to your patch, I found Util#getLineNumber especially difficult to read and to understand; having it specified could help sort out what is expected, especially the parameters domains; I've not proved it formally, but the use of while (g <= d) might be replaced by a while (g < d), saving an iteration and a noop assignment in some cases, provided that the case when position matches a line separator be handled properly.
Comment 7 Olivier Thomann CLA 2007-05-23 11:48:27 EDT
(In reply to comment #6)
> Olivier, I'm afraid a few things look odd to me, but this may come from a lack
> of familiarity with that code area:
> - on line 5784, I don't see how we could have length equal to 0; if it were so,
> we would have no line separator, hence the method would be on a single line and
> we would have executed line 5778 instead?
> - I am not sure why you are passing this.lineNumberEnd - 1 to getLineNumber; is
> that to save a loop iteration? if so, this would deserve a comment.
> I've not dug deeper so far, since I'd like to better understand the overall
> picture.
I'll provide a new patch for these issues.
Comment 8 Olivier Thomann CLA 2007-05-23 14:00:38 EDT
Created attachment 68398 [details]
Proposed fix

Since with the fix for bug 188656, we are back to M7 perfs, I would move this one to 3.3.1 instead of 3.3RC2. This would give us more time to test this patch.
Comment 9 Maxime Daniel CLA 2007-05-23 15:47:19 EDT
If we no more *need* it for 3.3, I vote +1 for deferring to 3.3.1. My first reading gave me the feeling that the fix was far from being trivial. I'd also support some reconsideration of Util#getLineNumber, and maybe some white box testing as well (this is not the norm in the team since we prefer user level test cases by any measure, but a nicely separated complex algorithm is especially suited to white box testing, IMHO).
Comment 10 Philipe Mulet CLA 2007-05-23 17:03:47 EDT
I am fine to defer until 3.3.1.
Comment 11 Olivier Thomann CLA 2007-05-23 17:10:40 EDT
Moving to 3.3.1.
Comment 12 Olivier Thomann CLA 2007-07-30 22:36:56 EDT
Created attachment 74989 [details]
Update previous patch for HEAD contents

Resynch the previous patch with actual HEAD contents.
Comment 13 Philipe Mulet CLA 2007-08-29 06:35:35 EDT
Thinking again, why are we considering a minor perf improvement for a maintenance release ? Feels like asking for trouble, and thus this should go in 3.4 only.
Comment 14 Olivier Thomann CLA 2007-08-31 15:39:49 EDT
Released for 3.4M2.
To verify, an improvement should be noticeable in the performance tests. 
Comment 15 David Audel CLA 2007-09-18 10:44:46 EDT
Verified for 3.4M2