Closed Bug 344298 Opened 19 years ago Closed 19 years ago

importxml.pl performance problem

Categories

(Bugzilla :: Bug Import/Export & Moving, defect)

2.22
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 2.22

People

(Reporter: vrb, Assigned: vrb)

References

Details

Attachments

(1 file, 1 obsolete file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4 The importxml.pl script takes an extremely long time (half an hour or more) to process an XML file if it contains large (several MB) attachments. I will attach a workaround for this problem. Reproducible: Always Steps to Reproduce: 1.Use importxml.pl to import a file that contains a 5MB attachment. 2. 3. Actual Results: It takes over half an hour on a reasonably modern Pentium 4. Expected Results: It should take less time. :-)
Attachment #228864 - Flags: review?(ghendricks)
With this patch, importxml.pl can process a file with five 5MB attachments (total of 25MB) in 4.5 seconds on a 1400MHz Pentium III. Without the patch, I stopped the stopwatch after 45 minutes. :-)
Comment on attachment 228864 [details] [diff] [review] workaround for performance problem >+ elsif ($encoding =~ /filename/) { >+ # read the attachment file >+ Error("attach_path is required", undef) unless ($attach_path); >+ my $attach_filename = $attach_path . "/" . $attach->field('data'); What happens if I am running this on Windows? >+ Error("cannot open $attach_filename", undef) unless >+ open(ATTACH_FH, $attach_filename); Nit: I think this would be more readable (an more standard) as open(...) or Error() >+ undef $/; >+ $attachment{'data'} = <ATTACH_FH>; >+ close ATTACH_FH; >+ $/ = "\n"; Perl Best Practices suggests you use $variable = do { local $/; <HANDLE> }; This ensures that $/ does not get reset globally. Also, how do you know that $/ was \n in the first place? Again, what if this was on Windows?
Attachment #228864 - Flags: review?(ghendricks) → review-
Attached patch take 2Splinter Review
Good suggestions -- thanks.
Attachment #228864 - Attachment is obsolete: true
Attachment #228876 - Flags: review?(ghendricks)
FWIW: even better is to use IO::File and use the methods for slurping in the whole file. Also, somebody should confirm this bug if it's a confirmed problem.
Assignee: import-export → vrb
OS: Linux → All
Hardware: PC → All
Summary: workaround for importxml.pl performance problem → importxml.pl performance problem
Both vrb and Myself can definitely confirm this as a legitamate problem.
OS: All → Linux
Hardware: All → PC
Status: UNCONFIRMED → NEW
Ever confirmed: true
Status: NEW → ASSIGNED
OS: Linux → All
Hardware: PC → All
Comment on attachment 228876 [details] [diff] [review] take 2 Works nicely.
Attachment #228876 - Flags: review?(ghendricks) → review+
Flags: approval?
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → ASSIGNED
Flags: approval? → approval+
Flags: approval2.22?
Target Milestone: --- → Bugzilla 2.22
Version: unspecified → 2.22
Flags: approval2.22? → approval2.22+
tip: Checking in importxml.pl; /cvsroot/mozilla/webtools/bugzilla/importxml.pl,v <-- importxml.pl new revision: 1.62; previous revision: 1.61 done 2.22: Checking in importxml.pl; /cvsroot/mozilla/webtools/bugzilla/importxml.pl,v <-- importxml.pl new revision: 1.47.2.5; previous revision: 1.47.2.4 done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago19 years ago
Resolution: --- → FIXED
Blocks: 437169
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: