-
Notifications
You must be signed in to change notification settings - Fork 136
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
CompactWhitespaces poor performance causes problems with big attachments #68
Comments
90 seconds to handle a message is quite long, this shouldn't happen. Currently I can't investigate the problem but will look into it in a week or so. You can try to send multiple emails with different attachment sizes (1MB, 2MB, .... up to 20MB) and tell me which one don't go through, this would speedup my work. Thanks |
Thanks for the quick response. I've managed to send emails of the following sizes (larger take longer as I'd expect from your suggestion about calculating the body hash): |
Interesting development.... after looking at the code and seeing the section in GetBodyHash about relaxed canonicalisation I decided to set my configuration to simple as a test.... the emails go through fine! Looks like the bottleneck could be in the "CompactWhitespaces" function? |
Yes, that is most probably the problem, this code part has some quite costly function calls and loops. This should be replaced with a RegEx since those have a much higher performance. |
The problem could be with this function too. It's really delicate to change one of this two functions. :/ May be we could find some inspiration here : https://github.com/dmcgiv/DKIM.Net
|
@Pro : I have some problems with my developpement environnement. Can you identify with one of this two functions is in problem?
|
The DKIM.Net project uses the following function for compact whitespaces: I've also found an interesting discussion: http://stackoverflow.com/questions/6442421/c-sharp-fastest-way-to-remove-extra-white-spaces Regarding the Header parsing, maybe we can find a good performing MIME parser which we can integrate to get all the headers of the mail: @AlexLaroche We should implement the changes in another branch and test them thourugly before adding them back to the master branch. I'll do some tests to find out which function causes the long processing time. |
@Pro : An another way to do the implementation is to make a wrapper to the c library libopendkim (http://www.opendkim.org/libopendkim/) that we call for signing. This library is part of OpenDKIM project (http://www.opendkim.org/) and OpenDKIM project seem to be a reference for DKIM implementation. The current library isn't made to be build on Windows officially but we could try to made a easy adaptation. |
Yes, this would also be a good option. But this still needs a parser for header fields. Do you want to investigate if it's possible to use libopendkim in our code? |
I think if we could use libopendkim, the code no more need to make header parsing... We just past the parameters (SigningAlgorithm, HeaderCanonicalization, BodyCanonicalization, HeadersToSign, Private Key) to the wrapper. The wrapper will past all the stuff to libopendkim and exposed some methods of the library. We just have to let the library do all the signing job after. |
I will investigate the use of libopendkim in our code. |
Yep, but looking at http://www.opendkim.org/libopendkim/overview.html, you need to add each header separately with http://www.opendkim.org/libopendkim/dkim_header.html |
|
Just remove the header relaxed canonicalization case should probably fix the function GetCanonicalizedHeaders(). I don't think the problem is with parsing header. We don't have the problem in simple canonicalization mode. |
Yes, this should be fine to use for libopendkim since it does the canonicalization by itself. |
Do you have identify with one of this two functions is in problem? |
Do you have identify with one of this two functions is in problem? It will be to much work to try to use libopendkim. Libopendkim need to be port to Windows and a c++/cli wrapper should be develop. |
I investigated the performance of the two functions. I tested with a 1MB file attachment.
So the bottleneck is definetly the CompactWhitespaces method. I'll check if this function can be rewritten for better performance. |
Well, the problem was that we added each line directly to the string variable, e.g. |
Very small change but a big performance improvement. Good job! |
Hi,
Bit of an odd one here. DKim signer has been working well for us but today noticed that our email had ground to a halt. Discovered that for certain emails they seem to get stuck in the submissions queue and the EdgeTransport starts using excessive CPU and memory. Disabling the DKim Signer agent and restarting the MSTransportAgent allows the messages to leave the server and everything returns to normal.
I'm also periodically seeing the following in the event viewer: (source: MSExchange Extensibility)
"The execution time of agent 'Exchange DkimSigner' exceeded 90000 milliseconds while handling event 'OnCategorizedMessage' for message with InternetMessageId: 'Not Available'. This is an unusual amount of time for an agent to process a single event. However, Transport will continue processing this message."
So far it seems to occur with emails with attachments / over a certain size. Smaller emails seem to go through ok.
We're a design agency so some of our emails are proofs of 6-10mb in size.
Any ideas?
James.
The text was updated successfully, but these errors were encountered: