mail icon indicating copy to clipboard operation
mail copied to clipboard

Improve performance of Message#find_attachment

Open bpot opened this issue 9 years ago • 5 comments

This is faster because we,

  • Don't trigger exceptions for flow control.
  • Retrieve each header only once (at most).

The exceptions this was throwing were particularly expensive for us on jruby. This change cut our mail processing time in half for a particular task.

The tests are passing with this change but it's possible that the rescues in the previous code were catching other exceptions that will now bubble up. We could add a rescue to find_attachment_filename to catch those.

bpot avatar Nov 01 '14 20:11 bpot

:+1: causing and catching exceptions is super-messy

@jeremy @bf4

grosser avatar Nov 24 '14 17:11 grosser

@grosser cleaned up the duplication in #find_attachment_filename. I like to avoid using #send if possible.

bpot avatar Dec 02 '14 02:12 bpot

@jeremy @bf4

grosser avatar Dec 02 '14 03:12 grosser

Is there a benchmark you used that we can run to test against regressions?

bf4 avatar Dec 02 '14 06:12 bf4

@bf4 I don't have anything that's easily extractable, I was profiling an application.

I agree a benchmark suite would be really useful.

bpot avatar Dec 02 '14 17:12 bpot