URL:
<http://savannah.gnu.org/patch/?6288>
Summary: 30% speedup by changing one MALLOC() to a CALLOC()
Project: grep
Submitted by: walles
Submitted on: tisdag 2007-11-27 den 17:04
Category: None
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
http://bugs.debian.org/450649
egrep becomes 30% faster in a real world use-case if you replace one malloc()
+ for() loop with a calloc(). Top of epsclosure(), dfa.c.
The real-world use case is running logcheck on my home system.
Details:
I've been profiling egrep since it uses lots of CPU when logcheck does its
thing.
In dfa.c, top of function epsclosure, we have this (with oprofile sample
counts):
: MALLOC(visited, int, d->tindex);
48796 16.2440 : for (i = 0; i < d->tindex; ++i)
94442 31.4394 : visited[i] = 0;
Replacing the home-made memset() loop above with doing CALLOC instead we
get:
: CALLOC(visited, int, d->tindex);
: // for (i = 0; i < d->tindex; ++i)
: // visited[i] = 0;
Zero samples. But obviously all that didn't just disappear. It went into
memset:
samples % image name app name symbol
name
60474 22.3932 libc-2.6.1.so libc-2.6.1.so memset
So instead of taking 50% of the CPU time with MALLOC(), it takes 22% with
CALLOC().
Please change MALLOC() to CALLOC() and remove the loop.
Regards //Johan
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/patch/?6288>
_______________________________________________
Meddelandet skickades via/av Savannah
http://savannah.gnu.org/