PreMailer.Net icon indicating copy to clipboard operation
PreMailer.Net copied to clipboard

Performance enhancement request for processing bulk html messages

Open cwinkelmann2 opened this issue 7 years ago • 5 comments

We're using PreMailer.Net to process large batch emails for occasional nightly runs. We generate the email content at about 1000 / 200ms. In-lining css will take about 40 seconds for the same 1000 messages. The problem is we're passing in the same css document on the MoveCssInline() method. I can't help but think there's lots of room to pass in a parsed version (some object) of that css so save the work of parsing that document each time we want to inline css on an html message.

Perhaps there is capability of doing this already. I was not able to figure it out by looking at the objects in the namespaces.

Comments / Suggestions are very welcome! Thanks greatly, Chris

cwinkelmann2 avatar Oct 19 '16 20:10 cwinkelmann2

Just want to understand this fully.

Have you profiled MoveCssInline and seen that the actual parsing of CSS into objects is taking the most time?

Or is it the entire operation that takes 40 seconds?

Another approach would be to inline the template - and add replacements based on data afterwards. That way you only inline onces - but it is not always possible to do it that way - it depends on your customization of templates based on recipients.

martinnormark avatar Oct 19 '16 21:10 martinnormark

Generate HTML (source) is 200ms / 1k messages MoveCssInline() takes 3.6 sec / 1k messages (when there's a small stylesheet embedded in HTML) MoveCssInline() takes 47 sec / 1k messages total when we pass in a larger stylesheet as a string parameter.

I'm curious if we can pass in a stylesheet on MoveCssInline() method in a object / format that is already parsed to avoid performing the same work 1k or 300k times on a run.

The template is a Razor script and would not be that easy to inline. If we did that, then we would not need PreMailer.Net.

I hope that makes the issue more clear. Thanks,

cwinkelmann2 avatar Oct 19 '16 22:10 cwinkelmann2

Ok, I see. Perhaps something can be done to make it easier to inline several HTML templates using the same CSS.

Razor makes it hard to inline before adding values into the template. If you used another way to insert values e.g. replacing ¤tokennames¤ or something as primitive it would be possible to do up-front - but that is of course not as nice as using Razor.

martinnormark avatar Oct 19 '16 22:10 martinnormark

I have a bug fix relating to performance and an enhancement for performance I'd like to push in a new branch. I'm not very familiar with git or how to accomplish this with your group. Perhaps I can have some advice and you can review and incorporate my changes.

Thanks

aztec2step avatar Oct 30 '16 04:10 aztec2step

@aztec2step If you haven't already done so, you should start out by forking this repo and then apply your changes to your own fork of this repo.

When you have done the changes you want to get integrated into PreMailer.Net, you submit a Pull Request from your fork.

That will create a new Pull Request issue in the PreMailer.Net repo that can be reviewed and merged into master.

martinnormark avatar Oct 31 '16 19:10 martinnormark