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

Slowness on writing files #348

Open
gomezdegomera opened this issue Oct 23, 2023 · 1 comment
Open

Slowness on writing files #348

gomezdegomera opened this issue Oct 23, 2023 · 1 comment

Comments

@gomezdegomera
Copy link

gomezdegomera commented Oct 23, 2023

Using jcifs-ng library, when writing a file from local folder to an smb folder, I register a transfer rate of about 7MB/s.
Instead, using the windows shell copy function for the same local file and the same smb folder the transfer rate is 80/s (10 times more).
I have the same problem for all files, smb folders and smb shares.
I noticed that transfer rate limit exists on single file; I mean that writing 2 files in parallel the transfer rate is about 14MB/s.

I have this configuration:

jcifsProperties.setProperty("jcifs.smb.client.enableSMB2", "true");
jcifsProperties.setProperty("jcifs.smb.client.useSMB2Negotiation", "true");
jcifsProperties.setProperty("jcifs.smb.client.attrExpirationPeriod", "0");
jcifsProperties.setProperty("jcifs.smb.client.responseTimeout", "70000");
jcifsProperties.setProperty("jcifs.smb.client.soTimeout", "70000");

I'm using code like this:

out = new BufferedOutputStream(fileObject.getContent().getOutputStream());
IOUtils.copy(in, out);

**
Could I have missed some optimization options on smb client?
Could it be a library issue (known one or not)?
Am I using a wrong approach for writing?**

Thanks

@mbechler
Copy link
Contributor

SMB performance largely depends on the read/write buffer/request size. The smaller, the more protocol overhead and also network latency starts to dominate over bandwidth (as every write requires a round-trip). Buffer sizes larger than 64k require the SMB 2.1 multi-credit feature, which unfortunately jcifs-ng does not currently support - therefore it definitely won't be able to achieve the same throughput as windows/samba/.... But you may want to check how large the buffers that IOUtils.copy are and make that at least 64k.

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

2 participants