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-164.html 10KB

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