[jcifs] Fast cache access patch

Jan Schlößin jan.schloessin at klero.de
Tue Feb 10 12:12:30 GMT 2009

Hello developers,

here comes a short patch for better name cache lookup throughput.
With this patch applied, my transfer runs _six_ times faster (many small
files with dozens of peers in parallel).

After revisal integrate it in the main development tree, please.

BTW. While browsing the source it comes to my mind that we can gain even
more throughput by reducing the number of mutual exclusions. May be with
 use of non blocking strategies. What do you think about?

-------------- next part --------------
diff -Naur jcifs_1.3.3/src/jcifs/UniAddress.java jcifs_1.3.3_fast_cache/src/jcifs/UniAddress.java
--- jcifs_1.3.3/src/jcifs/UniAddress.java	2009-01-25 14:34:14.000000000 +0100
+++ jcifs_1.3.3_fast_cache/src/jcifs/UniAddress.java	2009-02-10 12:15:19.312500000 +0100
@@ -160,6 +160,12 @@
     static NbtAddress lookupServerOrWorkgroup( String name, InetAddress svr )
                                                     throws UnknownHostException {
+        // if the name is cached, don't wait for any pending lookup
+        // return immediately
+        NbtAddress na = NbtAddress.getByName(name);
+        if (na != null) return na;
         Sem sem = new Sem( 2 );
         int type = NbtAddress.isWINS( svr ) ? 0x1b : 0x1d;

More information about the jcifs mailing list