Improve AOP binding by caching temp files

Description

If I create 100 objects that all have a single method with an AOP advice bound to it, WireBox creates 1000 identical temp files and deletes them. This creates a significant overhead of file system operations and compilation. It also eats up permgen space as a memory leak.

A quick test on my machine shows that I can create 1000 simple objects via WireBox in 900ms. However, adding a single aspect to a method increases that time to almost 17 seconds! A stack trace in FR shows file writes, deletes, and compilations. (And for comparison, the "new" keyword can create 1000 objects in 6ms) On an interesting note, disabling FusionReactor takes off about 600ms from both WireBox tests. It seems FR has some AOP slowness of its own.

Start caching the temp file and not deleting them so they can be reused. They can be cleared on injector startup or shutdown. If a naming convention is used that matches whatever parts of them are unique, then they can be easily indexed. Storing the names in memory will further reduce IO since you won't have to search the directory for them. I would recommend hashing the contents of the stub and using that as a key in the pool where the value is the path to the file.

Activity

Show:
Brandon Brown
November 21, 2017, 3:32 AM

I recently asked a question about doing this on Stackoverflow https://stackoverflow.com/questions/47360283/store-aop-objects-from-wirebox-inside-a-cache-or-make-aop-faster It would be great if the speed could be improved.

Fixed

Assignee

Luis Majano

Reporter

Brad Wood

Labels

None

Time tracking

0m

Time remaining

2h

Components

Fix versions

Priority

Major