Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EJB method takes more time to return after each call

I'm observing an unusual behaviour and I would like to understand what is happening.

Imagine a simple setup.

First I have a stateless bean that just returns something:

@Stateless
public class SimpleService{
    private Map<String, String> map;

    @PostConstruct
    public init(){
        map = new HashMap<>();
    }

    public Map<String,String> getMap(){
        return map;
    }
}

Then I have a another stateless bean that does some processing

@Stateless
public class ProcessService{

    private static final Logger log = LoggerFactory.getLogger(ProcessService.class);
    private static final int MAX = 2000;

    @Inject
    private SimpleService simpleService;

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void process(){
        final long start = System.currentTimeMillis();
        for(int i=0; i<MAX; i++){
            simpleService.getMap();
        }
        final long end = System.currentTimeMillis();
        log.info(MessageFormat.format("Process took {0} ms", end - start));
    }
}

Then I have a simple CDI bean to call the process method.

Result:

When I call the process method several times in a row, the process time keeps increasing:

Process took 900 ms
Process took 1,100 ms
Process took 1,200 ms
Process took 1,400 ms

And it keeps going up every time the method is called.

How can that be explained?

I'm using Java JDK 1.7.0_25 and JBOSS EAP 6.1.

EDIT

By the way, the only way to 'reset' the processing time for the method is to restart the server.

like image 671
phoenix7360 Avatar asked Jun 16 '14 13:06

phoenix7360


1 Answers

I have done testing with WildFly 8.1.0.Final and I get the following:

Process took 900 ms
Process took 600 ms
Process took 400 ms
Process took 300 ms
Process took 130ms
Process took 100ms

And then it stabilises itself around 90ms.

So I think we can safely assume that the original issue was a bug in JBoss AS 7 which was fixed in WildFly 8.1. More than fixed they even introduced some optimisation!

EDIT!

My apologies everyone, I made a wrong diagnostic. This error has nothing to the version of JBoss but was due by JRebel.

When I downloaded Wildfly, I didn't run it in debug mode with attached JRebel agent (which I was constantly doing with EAP 6.1). If I start JBoss EAP 6.1 without JRebel the problem doesn't happen.

I got so used to JRebel I forgot I had it switched on!

I will raise an issue with the JRebel team.

EDIT 2

JRebel team investigated and were able to reproduce the defect. It has been fixed in the nightly build and will be fixed in the next release (due August/September 2014)

like image 130
phoenix7360 Avatar answered Nov 01 '22 15:11

phoenix7360