[jcifs] Fast cache access patch

Michael B Allen ioplex at gmail.com
Tue Feb 10 16:25:00 GMT 2009


On Tue, Feb 10, 2009 at 7:12 AM, Jan Schlößin <jan.schloessin at klero.de> wrote:
> 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).

I don't think this patch is thread-safe. But I'm not sure, it's been a
while since I looked at that code. I've added it to the "TODO" for
further reference if I ever touch that code again.

Also, you might want to play around with the jcifs.resolveOrder
property. If you're seeing long delays, it might just be name queries
timing out.

Mike

> 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;

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jcifs mailing list