Encryption madness. Part III

On last week my colleagues were complaining about slow JMS performance on specific case: as a part of workflow they process tiff and pdf documents on JMS to place graphic stamp into content, and on 6.7SP1 everything was working smoothly, but on 7.2 this operation started taking a lot of time. The problem was following: during image processing they (i.e. my colleagues) create temporary files using File.createTempFile() method, ImageIO API in java also utilises File.createTempFile() method, so, I had counted about dozen of File.createTempFile() calls during one stamping operation, File.createTempFile() method is based on java.security.SecureRandom which is extremely slow in D7.2 environment, for example, following code

public class Test {

	public static final AtomicLong COUNTER = new AtomicLong(0);

	public static void main(String[] args) throws Exception {

		for (int i = 0; i < 100; i++) {
			new Thread(new Runnable() {
				@Override
				public void run() {
					try {
						while (true) {
							File.createTempFile("xxx", "xxx").delete();
							COUNTER.incrementAndGet();
						}
					} catch (IOException ex) {
						throw new RuntimeException(ex);
					}
				}
			}).start();
		}

		while (true) {
			long l = COUNTER.get();
			Thread.sleep(10000);
			System.out.println(COUNTER.get() - l);
		}

	}

}

demonstrates 100 times slower performance on JVM shipped with Content Server:

[dmadmin@docu72dev01 ~]$ type java
java is hashed (/u01/documentum/cs/shared/java64/1.7.0_72/bin/java)
[dmadmin@docu72dev01 ~]$ java Test
4302
5173
[dmadmin@docu72dev01 ~]$ export JAVA_HOME=/opt/java/jdk/sun/x86_64/jdk1.7.0_75
[dmadmin@docu72dev01 ~]$ $JAVA_HOME/bin/java Test
503042
518592

What the hell is going on? The answer is simple: EMC embedded extremely slowFIPS 140-2 enabled random number generator into JVM

4 thoughts on “Encryption madness. Part III

  1. Thanks for sharing this, is there any easy way to improve the performance? Changing the securerandom.source=file:/dev/urandom to securerandom.source=file:/dev/./urandom will help here anyway?

    Like

  2. Pingback: First OpenText document | Documentum in a (nuts)HELL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s