Bug 91417 - -Xreweavable should be the default
Summary: -Xreweavable should be the default
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M3   Edit
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Andrew Clement CLA
QA Contact:
URL: andrew.clement@gmail.com
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-14 11:16 EDT by Matthew Webster CLA
Modified: 2012-04-03 16:08 EDT (History)
0 users

See Also:


Attachments
partly complete patch (23.81 KB, patch)
2005-09-21 10:58 EDT, Andrew J Huff CLA
no flags Details | Diff
complete patch (15.27 KB, patch)
2005-09-23 09:39 EDT, Andrew J Huff CLA
aclement: iplog+
Details | Diff
loadtime and org.aspectj.ajdt.core again (7.44 KB, patch)
2005-09-27 10:42 EDT, Andrew J Huff CLA
no flags Details | Diff
one more time (3.69 KB, patch)
2005-09-28 09:57 EDT, Andrew J Huff CLA
aclement: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Webster CLA 2005-04-14 11:16:09 EDT
In order to facilitate widespread use of LTW we need to ensure code is 
compiled with –Xreweavable. However we cannot rely on developers to use this 
flag so it must be the default. Unfortunately the current code bloat is 
unacceptable for large projects.
Comment 1 Andrew Clement CLA 2005-04-15 03:15:41 EDT
Should try and look at this prior to 1.5.0 shipping.  Currently we have normal
reweavable which keeps a copy of the pre-woven class file, or
reweavable:compress which keeps a zipped (using ZipStream) copy of the pre-woven
class file.  

We need to look at some binary diff tools, and either:

- Just do a diff between the class bytes pre and post weave.

- Use more knowledge that we are diffing class files and perhaps process
different areas (constant pool, code attributes) differently.
Comment 2 Andrew Clement CLA 2005-05-12 05:37:49 EDT
See WeaverStateInfo.readAnyReweavableData and
WeaverStateInfo.writeAnyReweavableData.  That's where the improvements should go
- toughest bit will be getting hold of the bytes representing the finally woven
class as that must include everything *except* the WeaverStateInfo attribute
where the delta will be stored.
Comment 3 Andrew J Huff CLA 2005-05-24 08:04:49 EDT
Numbers and stuff
=================


I've made two additional versions of -Xreweavable:compress,

one which stores the DIFF of the unwoven file
and one which stores the COMPRESSED DIFF of the unwoven file.

SIZE ON DISK
============

				PROJECT SIZE	ZIPPED JAR SIZE
WOVEN				100%		48%
REWEAVABLE			152%		58%
REWEAVABLE:COMPRESSED		125%		75%
REWEAVABLE:COMPRESSED DIFF	110%		59%
REWEAVABLE:DIFF			115%		56%

These show some interesting results: compiling using reweavable:compressed
actually _increases_ the size of the outjar considerably! This is because the
second compression can't see that the zipped part of reweavable files is very
similar when unzipped to the non-zipped part of the reweavable files.

This means that reweavable:diff is the best overall, as people who care about
disk space usage will (should) be compiling to an outjar.

So overall:
From woven (not reweavable) to woven:reweavable using an outjar, the increase in
size was 120%
And now, from woven (not reweavable) to woven:reweavable (using diff) using an
outjar, the increase in size is 117%

So, I'm going to clean up my code a bit, add some unit tests and then perhaps
make "uncompressed diff" the default.
Comment 4 Andrew J Huff CLA 2005-05-24 08:32:32 EDT
Note, the project I used to get this data on consisted of 77 source files, 72 of
which were touched by aspects.
Comment 5 Andrew J Huff CLA 2005-05-24 08:52:03 EDT
If I'm going to make the uncompressed diff thing the default,
then -Xreweavable and -Xreweavable:compress will become depricated..

and perhaps a couple of extra -X options should be added:

-Xreweavable:noDiff

and

-XnoReweavable
Comment 6 Andrew Clement CLA 2005-05-24 11:48:21 EDT
What is the performance impact to the build time for the different modes?
Comment 7 Andrew J Huff CLA 2005-05-25 07:24:35 EDT
reweavable took 8.54 seconds
reweavable:compress took 8.69 seconds
and reweavable with the diff took 9.68 seconds

given that the test-project had 77 files,
diffing it would be 13.68 seconds longer than just doing it reweavable on a 1000
file project.

Thats too long, isn't it?
Comment 8 Andrew Clement CLA 2005-05-25 13:23:58 EDT
How long does it take to compile that program (77 files) with *no* reweavable
option specified?  It's not necessarily a problem that building 1000 file
project takes 13 seconds longer, since we will hopefully normally be doing
incremental compiles for single file changes, and as long as that remains near
instant (<1second) then we may be OK.

I'm just trying to decide the right conditions under which to make reweavable
the default.  Alex has already changed AJ so that aspects are always built
reweavable - the question is over what to do for normal classes...
Comment 9 Andrew J Huff CLA 2005-05-26 08:37:12 EDT
I've just made a new way of diffing the file, which I'm calling "DumDiff"

SIZE ON DISK
============
				PROJECT SIZE	ZIPPED JAR SIZE
WOVEN				100%		48%
REWEAVABLE			152%		58%
REWEAVABLE:DIFF			115%		56%
REWEAVABLE:DUMDIFF		122%		55%

DumDiff is incredibly fast
(at least ten times as fast as diff)
and it produces the smallest zipped-jar size...

so now I think DumDiff should become the default.
Comment 10 Andrew J Huff CLA 2005-05-26 08:42:27 EDT
the dumdiff reweavable method makes the project 114% of the size it would be
non-reweavable.
Comment 11 Matthew Webster CLA 2005-07-18 08:56:39 EDT
We should also remove -noweave at the same time because it is evil and will no 
longer be necessary.
Comment 12 Andrew J Huff CLA 2005-09-21 10:58:53 EDT
Created attachment 27338 [details]
partly complete patch 

Alright, having found that months ago I accidentally deleted the wrong
workspace, I've had to rewrite the diff thing I had. The good news is the new
version works and is better than the old one was :)

I'm including a patch here of what I've got so far just incase my computer
explodes..

it currently works the same as normal, but when -Xreweavable:compress is
specified it uses my diff thing....

I'll put another patch here soonish which will be back compatible with files
made with the old -Xreweavable:compress, and which will have all the options
wired up correctly, the new options will be:

(nothing)		the default makes classfiles reweavable using my diff
			  thing
-Xreweavable		the same as the default, but outputs a warning
-Xreweavable:compress	the same as the default, but outputs a warning
-Xnoweave		gives an error
-XnotReweavable 	makes non-reweavable classfiles

people should tell me now if they want the options to do different things!
Comment 13 Andrew Clement CLA 2005-09-21 11:36:39 EDT
dont change -Xnoweave!!  I know we don't like it but I use it all the time for
testing.
Comment 14 Andrew J Huff CLA 2005-09-21 12:34:15 EDT
acknowledged
Comment 15 Andrew J Huff CLA 2005-09-23 09:39:06 EDT
Created attachment 27436 [details]
complete patch

This zipped patch is synchronised and passes all the
run-these-before-you-commit tests.
Comment 16 Adrian Colyer CLA 2005-09-27 05:42:23 EDT
assigning to andy...
Comment 17 Andrew Clement CLA 2005-09-27 06:35:55 EDT
reminding myself that this is likely to break incremental compilation, watch out!
Comment 18 Andrew Clement CLA 2005-09-27 08:31:31 EDT
Andrew, I can't apply the entire patch (bloody linux).  I need you to sync and
recreate the patches *only* for the org.aspectj.ajdt.core module and the
loadtime module.  The others went on OK.
Comment 19 Andrew J Huff CLA 2005-09-27 10:42:56 EDT
Created attachment 27560 [details]
loadtime and org.aspectj.ajdt.core again

don't know if this'll work any better :-/
Comment 20 Andrew Clement CLA 2005-09-27 11:00:37 EDT
hmmmmm - did you sync before making those new diffs? they don't seem to take
account of -Xdev:pinpoint which is in the argument parsing logic now....  i'm
trying to hack them in regardless but it may go wrong.
Comment 21 Andrew J Huff CLA 2005-09-28 09:57:09 EDT
Created attachment 27614 [details]
one more time

damn whitespace!
Comment 22 Andrew Clement CLA 2005-10-05 07:58:18 EDT
This feature is about to go in.  I've been tweaking it a bit today and had to
change some option handling slightly so that it worked with some of the other
recent changes that have gone into CVS.

I thought I'd try it out building the biggest AJ project we have, Shadows.

           -XnotReweavable                               (default reweavable)
time to
build         ~41s                                           ~41s

Size of
bin directory
after build
            8532463bytes                                    9198561bytes

Zipped bin
directory
after build
            3760391bytes                                    3949184bytes

There are >1200 files in shadows.  Average impact is about 500bytes on each
7000byte class file, which is <10%

Comparing this with the old reweavable implementation:

Xreweavable: 9960142 bin dir, 4036844 zipped.
Xreweavable:compress: 9107662 bin dir, 4358636 zipped.

I am going to tag the tree before checking it in ... just in case ;)
Comment 23 Andrew Clement CLA 2005-10-05 08:24:53 EDT
well ... i've done it, this feature is now integrated into CVS.  it will be
interesting to see how well it behaves with AJDT.
Comment 24 Andrew Clement CLA 2005-10-06 04:36:55 EDT
reweavable is default *gulp*
Comment 25 Matthew Webster CLA 2005-10-12 15:56:52 EDT
I strongly suspect we should make -XnotReweavable  the default for LTW as is 
no doubt more expensive and redundant in that mode.