You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README-1.6.1.adoc 7.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. = AspectJ 1.6.1
  2. _© Copyright 2008 Contributors. All rights reserved._
  3. The main themes of AspectJ1.6.1 are better memory usage and faster
  4. weaving. This has been achieved through profiling of the weaving process
  5. and has resulted in some serious refactoring of the weaver component
  6. within AspectJ. It provides exactly the same functionality as in
  7. previous releases, it just weaves faster now, using less code and less
  8. memory. This readme will give an overview of the kind of changes made
  9. and what can be expected when using 1.6.1 compared to previous releases.
  10. The complete list of issues resolved for AspectJ 1.6.1 can be found with
  11. these bugzilla queries. The first lists bugs addressed (more than 60!)
  12. whilst the second details enhancements made in this release.
  13. * https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=AspectJ&target_milestone=1.6.1&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&bug_severity=blocker&bug_severity=critical&bug_severity=major&bug_severity=normal&bug_severity=minor&bug_severity=trivial&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=[Bugs
  14. resolved]
  15. * https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=AspectJ&target_milestone=1.6.1&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&bug_severity=enhancement&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=[Enhancements
  16. implemented]
  17. '''''
  18. == Refactored (https://bugs.eclipse.org/bugs/show_bug.cgi?id=231396[bug 231396])
  19. The bugzilla entry goes into more specifics on what has changed, the end
  20. result is that aspectjweaver.jar has had around 275 classes removed
  21. (about 25%) and has slimmed down by 350k (about 20%). In terms of
  22. performance for different scenarios:
  23. === Straight compilation
  24. The refactoring effort has been focused on the weaver component, hence
  25. there is limited impact on the performance of source compilation but
  26. this comparison shows it is faster. Four scenarios are compared, in each
  27. scenario a different aspect is applied to the JDT compiler (just as a
  28. sample piece of source code).
  29. . 1100 source files, few aspects that target 859 join points.
  30. . 1100 source files, code style trace aspect targeting public methods
  31. (22000 join points)
  32. . 1100 source files, annotation style trace aspect (22000 join points)
  33. . 1100 source files, insane aspect (before(): within(*) \{}) (203000
  34. join points)
  35. image:images/perfSourceCompile_161.jpg[image]
  36. === Binary weaving
  37. Moving on from source compilation to pure binary weaving, the
  38. improvements are more obvious. Here we are using the complete JVM
  39. classes jar 'rt.jar' as an example of a large jar file for weaving.
  40. . Binary weaving rt.jar (~12000 classes) with a simple aspect (1200 join
  41. points)
  42. . Binary weaving rt.jar (~12000 classes) with a code style trace aspect
  43. (121000 join points)
  44. . Binary weaving rt.jar (~12000 classes) with an annotation style trace
  45. aspect (121000 join points)
  46. . Binary weaving rt.jar (~12000 classes) with an insane aspect
  47. (before(): within(*) \{}) (352000 join points)
  48. image:images/perfBinaryWeave_161.jpg[image]
  49. === Loadtime weaving
  50. The loadtime weaving improvements are similar to those seen for binary
  51. weaving (naturally). Here we are using the JDK tools jar 'tools.jar' as
  52. an example of a jar file for loadtime weaving.
  53. . Binary weaving tools.jar (~1900 classes) with a code style trace
  54. aspect
  55. . Binary weaving tools.jar (~1900 classes) with an insane aspect
  56. (before(): within(*) \{})
  57. image:images/perfLTW_161.jpg[image]
  58. The refactoring work has also reduced the amount of unnecessary garbage
  59. created on the heap during the weaving process. The next comparison
  60. shows roughly the reduction in amount of 'stuff' created on the heap
  61. during a weave. This isn't the max heap required to do a weave, it is
  62. just showing how many less temporary objects are allocated during an
  63. entire run of the weaver
  64. . First, the number of kilobytes of memory allocated from the heap
  65. during a weave of tools.jar with a code style trace aspect
  66. . Second, another run of the same thing
  67. . Third, this time using the insane aspect
  68. image:images/heapContents_161.jpg[image]
  69. So in terms of memory required, weaving the insane aspect into tools.jar
  70. created 1.4G of 'stuff' over the entire weaving process, compared to
  71. 1.75G with 1.6.0.
  72. === Loadtime weaving stress
  73. As well as addressing the memory usage of a single load time weaver, we
  74. have also looked at the use of load time weaving in a larger scale
  75. scenario, where multiple classloaders are being instantiated and
  76. discarded over time and each has an associated load time weaver. Under
  77. https://bugs.eclipse.org/bugs/show_bug.cgi?id=210470[bug 210470] we
  78. looked in detail at whether the lifecycle of the weaver instance
  79. correctly matched the lifecycle of the associated classloader. It did
  80. not, but now it does! Here is a memory usage graph for AspectJ1.6.1 -
  81. this shows an application that spawns 7 threads which run continuously
  82. for a few minutes. Each thread repeatedly creates a classloader, weaves
  83. 500 classes using it then discards the classloader. You can see that
  84. over time the memory is recovered correctly and when all threads
  85. complete (and all classloaders are orphaned), all the weavers are
  86. discarded.
  87. First, AspectJ 1.6.0, in which memory was never correctly recovered and
  88. so an OutOfMemory problem would always occur eventually.
  89. image:images/memLtwStress_160.jpg[image]
  90. And now AspectJ 1.6.1:
  91. image:images/memLtwStress_161.jpg[image]
  92. == Incremental compilation
  93. Following on from the work done to improve compilation under Eclipse in
  94. AspectJ 1.6.0 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=221427[Bug
  95. 221427] ) - we now support the building of 'broken code'
  96. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=102733[bug 102733]). This
  97. is something the JDT has always been doing - where code containing
  98. errors continues to build (if recovery is possible) but should the
  99. actual methods containing the errors get invoked, an exception will be
  100. thrown at runtime. A number of users typically extract large projects
  101. from their library systems, knowing that they will only partially build
  102. in their current eclipse setup, but as long at they do not invoke the
  103. code containing the errors then they expect the rest of the project to
  104. run normally. AspectJ now allows this mode of operation, and it has the
  105. additional effect that the state of the project stays consistent, albeit
  106. with known errors, and this means AspectJ will more frequently do
  107. incremental builds rather than falling back to full builds because there
  108. was a compilation error.
  109. == Language changes
  110. === Optmized syntax for annotation value binding (https://bugs.eclipse.org/bugs/show_bug.cgi?id=234943[Bug234943])
  111. If only binding an annotation at a method-execution join point in order
  112. to access an *enum value* within it, there is a more optimal syntax that
  113. can be used to produce faster code. Given this setup:
  114. [source, java]
  115. ....
  116. enum Colour { RED,GREEN,BLUE;}
  117. @interface ColouredAnnotation { Colour value(); }
  118. @ColouredAnnotation(Colour.RED)
  119. public void colouredMethod() { }
  120. ....
  121. Current syntax:
  122. [source, java]
  123. ....
  124. before(ColouredAnnotation anno): execution(* *(..)) && @annotation(anno) {
  125. printTheColour(anno.value());
  126. }
  127. ....
  128. New optional syntax:
  129. [source, java]
  130. ....
  131. before(Colour col): execution(* *(..)) && @annotation(ColouredAnnotation(col)) {
  132. printTheColour(col);
  133. }
  134. ....