Skip to content
Commit 301011ba authored by Steven Rostedt (VMware)'s avatar Steven Rostedt (VMware) Committed by Arnaldo Carvalho de Melo
Browse files

tools lib traceevent: Remove unneeded qsort and uses memmove instead



While reading a trace data file that had 100,000s of tasks, the process
took an extremely long time. I profiled it down to add_new_comm(), which
was doing a qsort() call on an array that was pretty much already sorted
(all but the last element. qsort() isn't very efficient when dealing
with mostly sorted arrays, and this definitely showed its issues.

When adding a new task to the task list, instead of using qsort(), do
another bsearch() with a function that will find the element before
where the new task will be inserted in. Then simply shift the rest of
the array, and insert the task where it belongs.

Fixes: f7d82350 ("tools/events: Add files to create libtraceevent.a")
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lkml.kernel.org/r/20190828191820.127233764@goodmis.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b0215e2d
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment