Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small readSize in SmbFileInputStream.java results in very low read speed from SMB share. #11

Open
HubKing opened this issue Mar 30, 2017 · 4 comments

Comments

@HubKing
Copy link

HubKing commented Mar 30, 2017

On my two Android devices, reading a file from an SMB share was very slow. The speed was about 0.3MB/s (the devices' Wi-Fi connection speed was 150Mbps). I checked the SMB packets on the Windows comptuer, and the read size was 4286.

A famous app called "Solid Explorer" is using this library, but showed faster copy speed (5MB/s). When I checked the SMB packets, its read size was set to 32768. The developers of Solid Explorer was using a modified version of JCIFS, and they had set a bigger read size.

When modified JCIFS just to set a bigger read size in , I could also achieve 5MB/s without modifying my app. I am not sure if this is a specific case of my devices or my Wi-Fi router, but please check if you could modify the library to use bigger read size when necessary.

@HubKing
Copy link
Author

HubKing commented Mar 31, 2017

This seems to be because JCIFS does not support CAP_LARGE_READX.

For example, my Windows computer returned 4356 for "MaxBufferSize" and 65536 for "MaxRawSize" when negotiating. In the constructor, maxBufferSize is 4356 and smaller, so readSize is set to 4286.

    readSize = Math.min( file.tree.session.transport.rcv_buf_size - 70,
                        file.tree.session.transport.server.maxBufferSize - 70 );

In readDirect, readSize (4286) is used as the maxCount for SmbComReadAndX.

         r = len > readSize ? readSize : len;
        try {
               SmbComReadAndX request = new SmbComReadAndX( file.fid, fp, r, null );

Acocrding to MSDN, if the client sets CAP_LARGE_READX, the server can return more than the "MaxBufferSize" up to 65,535 bytes, which significantly increases the read speed.

@etemplar
Copy link

Hello, HubKing.

Does one need to do something except increasing readSize value?

In my case, len value is always ~8000, so readSize val does not really affect anything - r becomes equal to len in readDirect.

Download speed is fixed near 12-14 MBps/s. Some other apps show speed around 100 MBps/s (as it should be).

I've also tried to set properties in main application class' onCreate() without any success:

       System.setProperty("jcifs.resolveOrder", "DNS");
       System.setProperty("jcifs.smb.client.snd_buf_size", "60416");
       System.setProperty("jcifs.netbios.client.writeSize", "65535 ");

Any help is appreciated, thanks

@SteveGreatApe
Copy link

Try applying the patch in https://github.com/kohsuke/jcifs/blob/master/patches/LargeReadWrite.patch, it made a big difference for me.

@Techguyash
Copy link

Try applying the patch in https://github.com/kohsuke/jcifs/blob/master/patches/LargeReadWrite.patch, it made a big difference for me.

Hi SteveGreatApe,
Can you please help me how to apply the patch. I am using 1.3.14 jar. The upload size is very slow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants