【发布时间】:2010-11-11 07:35:40
【问题描述】:
这是我关于堆栈溢出的第一个问题,请善待。
我正在运行一个应用程序
- 春天 2.5.x
- 可配置的注释
- 编译时编织 (CTW)
- 行家
- eclipse/ajdt
我使用 CTW,一切正常。但是如果我第一次实例化一个带注释的类需要很长时间。第二次非常快。
查看分析器堆栈跟踪的第一个调用,我看到 93% 的时间被 org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesMethodExecution(Method)
在第二次调用的堆栈跟踪中,只有 1% 的时间用于此方法。更糟糕的是:第一次调用的时间大约是第二次调用的 10 倍。
我想知道,因为我认为 CTW 不再需要织布工。
但似乎只有当有人在这个类上调用 new 时,Spring 才开始分析原型 bean。它使用 aspectj weaver 分析需要完成的工作,并为下一次调用做好准备以加快此过程。
有没有人有任何加速初始化注释类的第一次调用的经验?
这是我的 pom 的 sn-p:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-compile</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<complianceLevel>1.5</complianceLevel>
<source>1.5</source>
<showWeaveInfo>true</showWeaveInfo>
<outxml>true</outxml>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
</plugin>
【问题讨论】:
-
我认为这是 CTW 固有的。第一次调用必须完成所有繁重的工作来分析、编织和生成运行时类,而且非常昂贵。
-
它应该是 Load-time-weaving (LTW) 所固有的,而不是 CTW 所固有的!
标签: spring performance spring-aop configurable compile-time-weaving