Page 1 of 1

Java API performance issues

Posted: Wed Dec 09, 2015 2:48 am
by pempek
Hi,

We're using Java API of WURFL and we're experiencing performance problems because of that. Analyzing WURFL call tree shows that there are several calls to java.lang.Class.getSimpleName(). In the attached example there are 4 calls (marked in red) which consume 10% of total WURFL processing time. Would it be possible to remove or disable that code?

http://snag.gy/MrMgH.jpg

Secondly, RISMatcher.match() internally builds a new ArrayList (marked in blue), which consume 70% of WURFL processing time. Can we do something about that? Cache it or use some static data?

Cheers,
Przemek

Re: Java API performance issues

Posted: Wed Dec 09, 2015 1:58 pm
by aaronp
Hi Przemysław,

Could you let me know what version of the API you are currently running?

Aaron

Re: Java API performance issues

Posted: Thu Dec 10, 2015 2:07 am
by pempek
The screenshot was taken at 1.5.2.1, but we're now migrated to 1.6.3.0 and it's still the same case.

Re: Java API performance issues

Posted: Thu Dec 10, 2015 2:54 pm
by aaronp
Przemysław,

Try running version 1.6.4.0; it is the latest version and we have made performance enhancements. Let me know how that goes!

Aaron

Re: Java API performance issues

Posted: Fri Dec 11, 2015 6:28 am
by pempek
Upgraded to 1.6.4.0, does a little bit better, but mainly still the same issues. java.lang.Class.getSimpleName() consumes 1.8% CPU time out of 13.5% which WURFL consumes in overall. I'm preety sure those calls could be avoided/disabled.
RISMatches still consumes ~70% of overall WURFL processing time.

http://snag.gy/Bwnzl.jpg

Can you help us with that?

Re: Java API performance issues

Posted: Fri Dec 11, 2015 10:41 am
by aaronp
Przemysław,

Thanks for the heads up. We are currently in the process of replicating this issue.

Are you able to provide us with more details on the Java environment you are testing in and how you are profiling your tests? Also, will you be able to provide us with a code sample?

Aaron

Re: Java API performance issues

Posted: Fri Dec 11, 2015 11:58 am
by pempek
This is a snapshot of real code performance in our PROD servers. Our code is basically calling WURFLEngine.getDeviceForRequest(). The thing is that each server handles few thousand of requests per second. The side effect of that is high memory allocation rate (~350 MB/s) which is probably why we're seeing ArrayList.init() takes so long. It'd be beneficial if WURFL wouldn't create that list internally. Maybe it could use another object or cache user agents internally.

Re: Java API performance issues

Posted: Mon Dec 14, 2015 11:16 am
by aaronp
Przemysław,

Are you able to send us a code sample of how you are configuring your `WURFLEngine` object?

Thanks,

Aaron

Re: Java API performance issues

Posted: Tue Dec 15, 2015 2:59 am
by pempek
Sure.

Code: Select all

WURFLResource wurflResource = new XMLResource(file);
WURFLEngine wurflEngine = new GeneralWURFLEngine(wurflResource);
wurflEngine.setEngineTarget(EngineTarget.accuracy);
wurflEngine.getDeviceForRequest(""); // initialize

Re: Java API performance issues

Posted: Tue Dec 15, 2015 11:44 am
by aaronp
Przemysław,

I would suggest using a cache; preferably the double LRU cache driver (10,000/25,000) for best performance.

Also, we will be making several improvements in our next API release.

Aaron

Re: Java API performance issues

Posted: Wed Dec 16, 2015 2:34 am
by pempek
Do you mean:

Code: Select all

wurflEngine.setCacheProvider(new DoubleLRUMapCacheProvider(10_000, 25_000));
I'll try that and come back with results.

Re: Java API performance issues

Posted: Wed Dec 16, 2015 5:23 am
by pempek
I increased those values 10 times and now it works far better than at then beginning. Thanks for that tip and we're waiting for new version to come!:)

Re: Java API performance issues

Posted: Thu Dec 17, 2015 11:44 am
by aaronp
Przemysław,

Java 1.6.4.1 for both OnSite/InFuze will be available by tomorrow, if not today, in your file manager.

Aaron

Re: Java API performance issues

Posted: Mon Dec 21, 2015 7:24 am
by pempek
Ok. Waiting for it to appear :)

Re: Java API performance issues

Posted: Mon Dec 21, 2015 9:54 am
by aaronp
Hi Przemysław,

Java 1.6.4.1 has been released and you should have access to download.

Also, one of our engineers have notified me that the correct numbers are: double lru cache sixing is UA, deviceid. Good numbers are 100000, 25000 or 60000, 15000 (User Agent cache size, device cache size)

Code: Select all

wurflEngine.setCacheProvider(new DoubleLRUMapCacheProvider(100000, 25000));
Let me know if you still do not have access to the latest update!

Aaron

Re: Java API performance issues

Posted: Tue Dec 22, 2015 5:41 am
by pempek
Looks nicer, no calls to getSimpleName() are made. With the caching added, our servers perform now far better. Thank you!