[Poppler-bugs] [Bug 89096] New: [patch] reduce use of gmalloc() in GooString::appendfv()
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Wed Feb 11 20:04:02 PST 2015
https://bugs.freedesktop.org/show_bug.cgi?id=89096
Bug ID: 89096
Summary: [patch] reduce use of gmalloc() in
GooString::appendfv()
Product: poppler
Version: unspecified
Hardware: Other
OS: All
Status: NEW
Severity: normal
Priority: medium
Component: general
Assignee: poppler-bugs at lists.freedesktop.org
Reporter: williambader at hotmail.com
Created attachment 113383
--> https://bugs.freedesktop.org/attachment.cgi?id=113383&action=edit
patch to GooString::appendfv()
In the test file in https://bugs.freedesktop.org/show_bug.cgi?id=89076 pdftops
spends the most time in GooString::formatDouble() and GooString::appendfv().
GooString::appendfv() calls gmallocn() to allocate a small buffer of arguments
to print each time that it is called.
pdftops can call it millions of times on some PDFs.
These patches change appendfv() to use a local buffer with 8 items (the same as
it used to allocate). It now allocates a buffer only if it has more than 8
items. I tested the change by setting the initial size to 1 and running a file
with valgrind to exercise cases that require multiple reallocations.
I have profiles before and after showing that the number of calls to gmallocn()
was reduced from almost 11M to 4.8M and the total time spent inside appendfv()
and gmallocn() was reduced.
pdftops before the patch (total from 3 runs of "pdftops
2-DESCR_648853-IT-EN-DE_MANITOU_RIGENERATO.pdf x.ps")
% cumulative self self total
time seconds seconds calls ms/call ms/call name
15.25 0.93 0.93 8905797 0.00 0.00
GooString::formatDouble(double, char*, int, int, bool, char**, int*)
9.34 1.50 0.57 6172503 0.00 0.00 GooString::appendfv(char
const*, __va_list_tag*)
7.87 1.98 0.48 34515024 0.00 0.00
FlateStream::getHuffmanCodeWord(FlateHuffmanTab*)
7.05 2.41 0.43 22730064 0.00 0.00 FlateStream::readSome()
6.48 2.81 0.40 18514623 0.00 0.00 Lexer::getObj(Object*,
int)
5.90 3.17 0.36 16607355 0.00 0.00 Parser::getObj(Object*,
bool, unsigned char*, CryptAlgorithm, int, int, int, int, bool)
5.90 3.53 0.36 106901274 0.00 0.00
JBIG2Segment::~JBIG2Segment()
4.92 3.83 0.30 111594801 0.00 0.00 FlateStream::getChar()
4.34 4.09 0.27 38266749 0.00 0.00 Object::free()
3.69 4.32 0.23 87202734 0.00 0.00 Lexer::lookChar()
3.61 4.54 0.22 19199391 0.00 0.00 GooString::append(char
const*, int)
2.79 4.71 0.17 438 0.39 12.47 Gfx::go(bool)
2.62 4.87 0.16 38745 0.00 0.00
FlateStream::compHuffmanCodes(int*, int, FlateHuffmanTab*)
1.39 4.95 0.09 10967463 0.00 0.00 gmallocn
pdftops after GooString, appendfv reduced 0.57s to 0.50s, gmalloc reduced 0.09s
to 0.02s,
13.07 0.75 0.75 8905797 0.00 0.00
GooString::formatDouble(double, char*, int, int, bool, char**, int*)
8.77 1.25 0.50 6172503 0.00 0.00 GooString::appendfv(char
const*, __va_list_tag*)
8.60 1.74 0.49 22730064 0.00 0.00 FlateStream::readSome()
8.07 2.20 0.46 18514623 0.00 0.00 Lexer::getObj(Object*,
int)
7.19 2.61 0.41 111594801 0.00 0.00 FlateStream::getChar()
...
0.35 5.14 0.02 4794960 0.00 0.00 gmallocn
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler-bugs/attachments/20150212/536daef6/attachment.html>
More information about the Poppler-bugs
mailing list