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.4.adoc 9.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. = AspectJ 1.6.4
  2. _© Copyright 2009 Contributors. All rights reserved._
  3. * xref:#compilation[Compilation times]
  4. * xref:#language[Language enhancements]
  5. * xref:#bugsfixed[Bugs fixed]
  6. * xref:#whatsnext[What's next?]
  7. '''''
  8. [[compilation]]
  9. == Compilation times
  10. In AspectJ 1.6.4 the goal was to improve the IDE experience, through a
  11. combination of improved compilation speed (both full builds and
  12. incremental builds), improved support for multiple-project
  13. configurations, and improved feedback in the editor. The following
  14. sections go into details on each of those topics.
  15. *Full Compilation*
  16. As an example project, all the measurements here are based on the
  17. modified JDT compiler that AspectJ uses internally. It is 1100 source
  18. files and includes aspects that affect around 850 join points. Here are
  19. the full build times in AJDT:
  20. AJDT 1.6.3 (uses AspectJ 1.6.3)
  21. [source, text]
  22. ....
  23. 21352ms
  24. 21597ms
  25. 21502ms
  26. ....
  27. AJDT 1.6.5dev builds (use AspectJ 1.6.4)
  28. [source, text]
  29. ....
  30. 19811ms
  31. 19802ms
  32. 19504ms
  33. ....
  34. About 1.5-2 seconds faster for this example.
  35. *Incremental Compilation and multi-project scenarios*
  36. In most common project configurations there are multiple eclipse
  37. projects in some kind of dependency hierarchy. Depending on what changes
  38. in a top level project, those downstream may need to be rebuilt. The
  39. analysis around this area has greatly improved in AspectJ 1.6.4, and
  40. this has resulted in much reduced incremental build times. The example
  41. timed here is around 20 AspectJ projects in a hierarchy, and a change is
  42. made to a source file in the top level project and build times are
  43. observed for the downstream projects.
  44. The timings reported here are accessible to anyone with AJDT installed -
  45. just open the 'AJDT Event Trace View' and it will report ongoing
  46. information about what the compiler/weaver and AJDT are up to. Be aware
  47. that data is only recorded in this view if it is open - so for optimal
  48. performance it should be shutdown, but it is useful for debugging
  49. scenarios or collecting basic benchmark numbers. Within the event trace
  50. view output, the time recorded for 'time spent in AJDE' represents the
  51. time spent in the compiler: analysing what has changed on the classpath,
  52. building code, weaving code.
  53. Initially this is using AJDT 1.6.2 (which embeds AspectJ 1.6.3):
  54. [source, text]
  55. ....
  56. Type of change: adding a new method to a type
  57. Project build times (first one is the compile of our change, the rest are for downstream projects):
  58. 462ms, 4ms, 145ms, 8ms, 9ms, 287ms, 471ms, 222ms, 1028ms, 143ms, 505ms, 199ms, 261ms, 1224ms,
  59. 321ms, 704ms, 75ms, 233ms, 257ms
  60. Summary: Total time spent in the compiler for that change: 6558ms
  61. ---
  62. Type of change: whitespace change (adding just a harmless space character)
  63. Project build times (first one is the compile of our change, the rest are for downstream projects):
  64. 229ms, 5ms, 10ms, 9ms, 10ms, 79ms, 43ms, 62ms, 80ms, 37ms, 64ms, 32ms, 79ms,
  65. 154ms, 94ms, 189ms, 72ms, 144ms, 205ms
  66. Summary: Total time spent in the compiler for that change: 1597ms
  67. ....
  68. Now with AspectJ 1.6.5 dev builds (which embed AspectJ 1.6.4):
  69. [source, text]
  70. ....
  71. Type of change: adding a new method to a type
  72. Project build times (first one is the compile of our change, the rest are for downstream projects):
  73. 288ms, 3ms, 143ms, 2ms, 2ms, 162ms, 244ms, 89ms, 489ms, 113ms, 277ms, 108ms, 143ms, 626ms,
  74. 135ms, 260ms, 2ms, 96ms, 6ms
  75. Summary: Total time spent in the compiler for that change: 3188ms down from 6558ms
  76. Type of change: whitespace change (adding just a harmless space character)
  77. Project build times (first one is the compile of our change, the rest are for downstream projects):
  78. 101ms, 1ms, 1ms, 1ms, 0ms, 1ms, 1ms, 1ms, 1ms, 1ms, 0ms, 1ms, 1ms, 2ms, 0ms, 1ms, 0ms, 2ms, 2ms
  79. Summary: Total time spent in the compiler for that change: 118ms (down from 1597ms)
  80. ....
  81. Improvements all round, and almost instant builds now for whitespace
  82. changes, even in large project setups.
  83. In addition the compilation times are also improved in situations where
  84. AspectJ projects depend upon Java projects and where aspectpath is used.
  85. AJDT 1.6.5 dev builds also include some changes that really speed up
  86. builds.
  87. == Better editor feedback
  88. Under https://bugs.eclipse.org/bugs/show_bug.cgi?id=246393[bug 246393]
  89. the problem has been addressed where sometimes spurious errors would
  90. appear throughout the editor for a file in AJDT when just one single
  91. simple syntax errors exists. More detail on this problem can be found
  92. http://andrewclement.blogspot.com/2009/02/aspectj-fixing-reverse-cascade-errors.html[here].
  93. '''''
  94. [[language]]
  95. == Language Enhancements
  96. *Optimizing support for maintaining per join point state*
  97. The traditional way to maintain state on a per join point basis involves
  98. using the JoinPoint.StaticPart as a key into a map:
  99. [source, java]
  100. ....
  101. aspect X pertypewithin(*) {
  102. Map<JoinPoint.StaticPart,Timer> timerMap = ...
  103. Object around(): execution(public * *(..)) {
  104. Timer timerToUse = timerMap.get(thisJoinPointStaticPart);
  105. timerToUse.start();
  106. Object o = proceed();
  107. timerToUse.stop();
  108. return o;
  109. }
  110. }
  111. ....
  112. These map lookups are slow. In AspectJ 1.6.4 there is a new getId()
  113. method on the JoinPoint.StaticPart object. The ids for all affected join
  114. points within a target type are unique (and start from 0) - they are
  115. ideal for array lookups. So using this the above aspect can be
  116. rewritten:
  117. [source, java]
  118. ....
  119. aspect X pertypewithin(*) {
  120. Timer[] timerArray = ...
  121. Object around(): execution(public * *(..)) {
  122. Timer timerToUse = timerArray[thisJoinPointStaticPart.getId()];
  123. timerToUse.start();
  124. Object o = proceed();
  125. timerToUse.stop();
  126. return o;
  127. }
  128. }
  129. ....
  130. much faster. Just be aware that the ids are only unique within an
  131. affected target type - hence the use of pertypewithin in this example to
  132. ensure there is an aspect instance (and so a different array) for each
  133. advised type.
  134. See related https://bugs.eclipse.org/bugs/show_bug.cgi?id=89009[bug
  135. 89009] for the full discussion
  136. == @DeclareMixin
  137. The annotation style declare parents support (@DeclareParents) has been
  138. (rightly) criticized because it really does not offer an equivalent to
  139. what is possible with code style declare parents, it really offers a
  140. mixin strategy. It also has limitations such as the delegate instance
  141. used to satisfy any method invocations on an affected target cannot
  142. access the object instance for which it is acting as a delegate. To
  143. address these concerns a proper mixin notation has been introduced that
  144. makes it more clear that a mixin strategy is being employed and it
  145. addresses the problem of the mixin delegate accessing the affected
  146. target instance.
  147. The @DeclareMixin annotation is attached to a factory method which
  148. returns instances of the delegate. Here is a basic example:
  149. [source, java]
  150. ....
  151. // The factory method that can build the delegate instance is annotated with @DeclareMixin.
  152. // The annotation value defines the type pattern for targets of the mixin.
  153. // The parameter is the object for which a delegate is being constructed.
  154. // The interface that will be mixed in is the return value of the factory method.
  155. @DeclareMixin("org.xyz..*")
  156. public static SomeInterface createDelegate(Object instance) {
  157. return new SomeImplementation(instance);
  158. }
  159. ....
  160. More examples are xref:../adk15notebook/ataspectj.adoc#ataspectj-itds[here
  161. in the online documentation].
  162. Going forward attempts will be made to try and make @DeclareParents
  163. behave more like code style - if this cannot be done it is likely to be
  164. deprecated.
  165. '''''
  166. [[bugsfixed]]
  167. == Bugs fixed
  168. The complete list of issues resolved for AspectJ 1.6.4 (more than 70)
  169. can be found with this bugzilla query:
  170. * https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&product=AspectJ&target_milestone=1.6.4&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&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
  171. resolved]
  172. '''''
  173. [[whatsnext]]
  174. == What's next?
  175. *More incremental build enhancements*
  176. A number of situations still exist where incremental compile speeds
  177. still needs optimizing, particular when capabilities like aspectpath or
  178. inpath are used.
  179. *Build state persistence*
  180. Between restarts of Eclipse the state of each project is not recorded -
  181. hence full builds are required upon restart. The state (and associated
  182. relationship model) should be persisted between restarts, but both of
  183. these need a review first to ensure they are not larger than they need
  184. to be.
  185. *Memory consumption*
  186. Both for source compilation and load-time weaving scenarios. The size of
  187. the model in the IDE needs reviewing, and also the type map within the
  188. weaver. Although the type map uses Weak/Soft references to try and
  189. better control how it uses memory, the JVM policies for managing these
  190. references vary wildly and so some work needs to be done to allow for
  191. these differences.