2

Same code, same data. HashMap has around 40K entries, keyed by a String. Timing was determined with System.nanoTime().

Local:

2015-08-21 12:46:09,958 DEBUG PERFORMANCE_ISSUE:55 - containsKey took 44336

Deployed:

2015-08-21 11:17:43,901 DEBUG PERFORMANCE_ISSUE:55 - containsKey took 4657210

I'm thinking something with GC or swapping, but was looking for other ideas...

Kevin Pauli
  • 8,577
  • 15
  • 49
  • 70
  • You can analyze GC using VisualVm what is the difference between these 2 systems? – sherif Aug 21 '15 at 18:12
  • Is this consistently slower or just randomly? – Peter Lawrey Aug 21 '15 at 18:13
  • What is the difference in cofig of local and deployed env ? –  Aug 21 '15 at 18:14
  • 4
    How did you do the timing? [Java microbenchmarking is non-trivial!](http://stackoverflow.com/q/504103/4125191). – RealSkeptic Aug 21 '15 at 18:14
  • 2
    BTW You can have a 4 ms jitter on your system without a GC. The OS can cause this much delay esp if you don't have bare metal machine. – Peter Lawrey Aug 21 '15 at 18:14
  • Check the amount of memory assigned to Java (`-Xmx`). If the number is low on your server, Java may be running GC all the time. Try logging GC activity with `-Xloggc`. – Andreas Aug 21 '15 at 18:16

2 Answers2

0

You can check the following:

  • If both are running on same hardware. Check for the memory allocated to JVM. A very low memory can cause a good delay.
  • If they are on different machines (hardware) then check for currently used Memory and Processor which can affect the time to run a program.
  • Although it should not be an issue but you can also check for the java version in both cases.
Nitin Singhal
  • 591
  • 5
  • 6
0

Boy do I feel dumb. It wasn't the same code at all. The local code (fast) was using a java.util.HashMap, and, due to a situation I won't go into here, the deployed code (slow) was actually ending up with a scala.collection.convert.Wrappers$MapWrapper .

So copying the values from the MapWrapper into a real HashMap before invoking the slow algorithm has solved the issue.

I appreciate all of the suggested answers anyway. SO is a wonderful community. I'm tempted to delete this post but will leave it up in case it helps anyone else in future.

Kevin Pauli
  • 8,577
  • 15
  • 49
  • 70