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

Extreme performance degradation with MimeMessage#writeTo(OutputStream) #557

Open
veita opened this issue Apr 19, 2021 · 2 comments
Open

Comments

@veita
Copy link

veita commented Apr 19, 2021

Describe the bug
Writing MimeMessage#writeTo(OutputStream) to an unbuffered instead of a buffered output stream leads to extreme performance degradation by factors greater that 100.

To Reproduce
Steps to reproduce the behavior:

  1. Create 1000 MimeMessages in a loop and write them to an unbuffered output stream, e.g. java.nio.file.Files#newOutputStream(Path)
  2. Measure the time taken in comparison to buffered output streams.

Expected behavior
Either it should be documented that the MimeMessage#writeTo(OutputStream) requires a buffered output stream to get reasonable performance, or the method itself should use a (small) internal buffer to ensure reasonable write performance even in cases where no buffered output stream is used.

Desktop (please complete the following information):

  • OS: Windows 2012 Server, Windows 10

Mail server:

  • N.A.
@jmehrens
Copy link
Contributor

Buffering is handled at the transport layers where there are additional restrictions about if and when buffering can be used. I would assume that the benchmark results will vary based on the number of addresses, session properties, and content size and content type of the MimeMessage.

That said the simple change would be to add a see reference to java.io.BufferedOutputStream and later consider using transferTo inside of the various mime classes when we require JDK 9+.

@jmehrens
Copy link
Contributor

jmehrens commented Mar 6, 2024

Blocked by: #709

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