Re: [PATCH 5/5] perf synthetic events: Remove use of sscanf from /proc reading
From: Jiri Olsa
Date: Thu Apr 02 2020 - 09:41:13 EST
On Wed, Apr 01, 2020 at 04:39:45PM -0700, Ian Rogers wrote:
> The synthesize benchmark, run on a single process and thread, shows
> perf_event__synthesize_mmap_events as the hottest function with fgets
> and sscanf taking the majority of execution time. fscanf performs
> similarly well. Replace the scanf call with manual reading of each field
> of the /proc/pid/maps line, and remove some unnecessary buffering.
> This change also addresses potential, but unlikely, buffer overruns for
> the string values read by scanf.
>
> Performance before is:
> Average synthesis took: 120.195100 usec
> Average data synthesis took: 156.582300 usec
>
> And after is:
> Average synthesis took: 67.189100 usec
> Average data synthesis took: 102.451600 usec
>
> On a Intel Xeon 6154 compiling with Debian gcc 9.2.1.
I can see the speedup as well, thanks!
jirka