Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

README-167.html 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  2. <html> <head>
  3. <title>AspectJ 1.6.7 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.7 Readme</h1>
  20. <p>AspectJ 1.6.7 includes some radical internal changes. These improvements enable faster compilation, faster binary weaving,
  21. faster load time weaving and in some situations faster generated code.</p>
  22. <h2>Pointcut timers</h2>
  23. <p>Until 1.6.7 there has not really been a way to determine if it is just one of your pointcuts that is hurting your weaving
  24. performance. In 1.6.7 it is possible to turn on timers for pointcuts. These timers show
  25. the time spent in the weaver matching the pointcut components against join points. The details on this feature are
  26. here: <a href="http://andrewclement.blogspot.com/2009/11/aspectj-profiling-pointcut-matching.html">Profiling pointcut
  27. matching</a>. Basically by turning on the options '-timers -verbose' on the command line (or via Ant), output will be produced
  28. that looks a little like this:
  29. <pre><code>
  30. Pointcut matching cost (total=6532ms for 675000 joinpoint match calls):
  31. Time:482ms (jps:#168585) matching against
  32. (staticinitialization(*y*.()) && persingleton(SimpleAspect))
  33. Time:3970ms (jps:#168585) matching against
  34. (execution(* *t*.*(*)) && persingleton(SimpleAspect))
  35. Time:538ms (jps:#168584) matching against
  36. (execution(* *f*(..)) && persingleton(SimpleAspect))
  37. Time:1536ms (jps:#168584) matching against
  38. (execution(* java.lang.CharSequence+.*e*(..)) && persingleton(SimpleAspect))
  39. Time:4ms (jps:#662) matching against
  40. (within(*p*) && persingleton(SimpleAspect))
  41. </code></pre>
  42. <p>It shows the component, the number of joinpoints (jps) the weaver attempted to match it against and how many milliseconds were
  43. spent performing those matches. The options can also be turned on
  44. <a href="http://contraptionsforprogramming.blogspot.com/2009/11/getting-aspectj-pointcut-matching-timer.html"/>through AJDT</a>.
  45. Armed with this information you can optimize your pointcuts or post on the mailing list asking for help. The timers can even be
  46. turned on for load time weaving. </p>
  47. <h2>Faster matching</h2>
  48. <p>The changes to enable pointcut profiling enabled some targeted work to be done on the matching algorithms. These
  49. have remained unchanged for a few years, but in 1.6.7 have received a bit of an overhaul. 'Fast match' has
  50. been implemented for the execution() pointcut, drastically reducing weave times for heavy users of execution - more details
  51. <a href="http://andrewclement.blogspot.com/2009/11/aspectj-how-much-faster-is-aspectj-167.html">here</a>. The pointcut cost
  52. calculator (which is used to sort pointcuts to optimize matching speed) has been reviewed and after determining that
  53. this() ought to be considered cheaper than call() - any user combining those two pointcut designators should see an improvement
  54. (one users build time reduced from 38minutes to 6minutes with that change!).</p>
  55. <p>As well as faster matching there is also less exploration to determine a match. Visitors that walk hierarchies and discover
  56. methods now terminate as early as possible once they can determine something is a match or is definetly not a match. This reduces
  57. memory usage, speeds up weaving and reduces the occurrences of those annoying 'cantFindType' messages.</p>
  58. <h2>aop.xml processing</h2>
  59. <p>The processing of include/exclude entries in aop.xml has been rewritten. It now optimizes for many more common patterns. If
  60. a pattern is optimized then there is no need to ask the weaver to do an expensive include/exclude match. More details
  61. <a href="http://andrewclement.blogspot.com/2009/12/aspectj-167-and-faster-load-time.html">here</a>.
  62. <h2>Less need to tweak options for load time weaving</h2>
  63. <p>A number of options were previously configurable for load time weaving that were considered experimental. These options
  64. have now been tested enough in the field that they are considered fully reliable and are on by default in 1.6.7. If you have
  65. been using either of these:
  66. <ul>
  67. <li>typeDemotion
  68. <li>runMinimalMemory
  69. </ul>
  70. <p>then please delete them from your weaver options section, the weaver will now do the right thing out of the box.</p>
  71. <h2>Benchmarking memory and performance</h2>
  72. <p>All those changes above, and some additional tweaks, mean we are now using less memory than ever before and getting
  73. things done more quickly.</p>
  74. <p><a href="http://andrewclement.blogspot.com/2009/12/aspectj-167-and-faster-load-time.html">This post</a> discusses
  75. the details. From that article, the graph below shows the speed and memory consumption of the
  76. various AspectJ 1.6 releases when load time weaving a small application loading in Tomcat. For each of 10 iterations (x axis),
  77. the top comparison is startup time in
  78. milliseconds, the lower comparison is memory used in bytes.</p>
  79. <p><img src="167Memory.png" align="center"/></p>
  80. <h2>Annotation binding</h2>
  81. <p>All those changes affect compilation/weaving but what about the code that actually runs? One user, Oliver Hoff, raised
  82. a query on the performance of annotation binding. His case uncovered an old TODO left in the code a few years ago:</p>
  83. <code><pre>// OPTIMIZE cache result of getDeclaredMethod and getAnnotation?</pre></code>
  84. <p>Annotation binding has become a very common use case since that was written and 1.6.7 was the time TODO it.</p>
  85. <p>The result is an optimization for the general case of binding an annotation, but also support for a new bit of syntax
  86. that aids binding of a string annotation member value - using this latter syntax generates extremely fast code.</p>
  87. <p>Here are some numbers for a simple benchmark retrieving the annotation value at an execution join point
  88. in different ways. The three scenarios look like this (where the annotation type is 'Marker' and it has a String value field
  89. called 'message'):</p>
  90. <code><pre>
  91. // CaseOne: annotation value fetching is done in the advice:
  92. pointcut adviceRetrievesAnnotation(): execution(@Marker * runOne(..));
  93. before(): adviceRetrievesAnnotation() {
  94. Marker marker = (Marker) ((MethodSignature)
  95. thisJoinPointStaticPart.getSignature()).getMethod().getAnnotation(Marker.class);
  96. String s = marker.message();
  97. }
  98. // CaseTwo: annotation binding is done in the pointcut, advice retrieves message
  99. pointcut pointcutBindsAnnotation(Marker l): execution(@Marker * runTwo(..)) && @annotation(l);
  100. before(Marker l): pointcutBindsAnnotation(l) {
  101. String s = l.message();
  102. }
  103. // CaseThree: annotation binding directly targets the message value in the annotation
  104. pointcut pointcutBindsAnnotationValue(String msg):
  105. execution(@Marker * runThree(..)) && @annotation(Marker(msg));
  106. before(String s): pointcutBindsAnnotationValue(s) {
  107. // already got the string
  108. }
  109. </pre></code>
  110. <p>Before 1.6.7, case 2 was slower than case 1 and case 3 wasn't supported syntax. The two bugs with more info are
  111. <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=296484">Bug 296484</a> and
  112. <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=296501">Bug 296501</a>.</p>
  113. <p>Now this is a micro benchmark, slightly unrepresentative of the real world because the advice isn't doing anything
  114. else, but it does really stress the AspectJ binding code. For the benchmark numbers the join points advised by those advice
  115. were invoked 1,000,000 times. AspectJ 1.6.7:</p>
  116. <code><pre>
  117. Manually fetching annotation with getAnnotation(): 645ms
  118. Binding annotation with @annotation(Marker): 445ms (was >20 *seconds* for 1.6.6, due to an extra reflection call)
  119. Binding annotation value with @annotation(Marker(message)): 3ms
  120. </pre></code>
  121. <p>The new syntax is definetly the best way to bind an annotation string value.</p>
  122. <hr>
  123. <a name="bugsfixed"/>
  124. <h4>Bugs fixed</h4>
  125. <p>The complete list of issues resolved for AspectJ 1.6.7 can be found with
  126. this bugzilla query:
  127. <ul>
  128. <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.7&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>
  129. </ul>
  130. <hr>
  131. <h4>
  132. <!-- ============================== -->
  133. </body>
  134. </html>