bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch #6288] 30% speedup by changing one MALLOC() to a CALLOC()


From: Johan Walles
Subject: [patch #6288] 30% speedup by changing one MALLOC() to a CALLOC()
Date: Tue, 27 Nov 2007 16:04:52 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; sv-SE; rv:1.8.1.10) Gecko/20071126 Ubuntu/7.10 (gutsy) Firefox/2.0.0.10

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/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]