|Subject:||MIME/Parser/Reader thinks a File::Temp object is not capable of native I/O|
|Date:||Fri, 18 Nov 2011 21:04:17 +0100|
|To:||bug-MIME-tools [...] rt.cpan.org|
|From:||Mark Martinec <Mark.Martinec [...] ijs.si>|
Using: MIME-Tools 5.502, perl 5.14.1 . While investigating poor performance of MIME::Parser on processing larger mail message with attachments (lots of 77-byte lines), it turns out that read_chunk() chooses a slow branch, thinking that a temporary output file created by File::Temp::new is not capable of native I/O, based on a wrong verdict from native_handle(). From the File::Temp man page: Note that there is no method to obtain the filehandle from the File::Temp object. The object itself acts as a filehandle. Also, the object is configured such that it stringifies to the name of the temporary file, and can be compared to a filename directly. The object isa "IO::Handle" and isa "IO::Seekable" so all those methods are available. So what is missing is a line like: return $fh if $fh->isa('IO::Handle'); in native_handle(). On a side track, printing thousands of 77-byte lines is not terribly efficient. Buffering up helps a little. Rewriting the read_chunk() to do its I/O by chunks instead of line-by-line could provide an impressive speedup (but this is beyond the scope of this PR). Attached is a small patch: it lets native_handle() recognize a temporary file object as provided by File::Temp as being native, and adds a little buffering to the native+native branch of read_chunk(). This provides some speedup in parsing large mail with B64 attachments (of the order of 10 %). Not too impressive, but every little bit helps. Btw, the Devel::NYTProf perl module is a tremendous tool for spotting bottlenecks in perl code! Regards Mark
Message body is not shown because sender requested not to inline it.