libunwind-devel
[Top][All Lists]
Advanced

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

Re: [Libunwind-devel] Fast stack trace utility for Linux


From: Vladimir Nikulichev
Subject: Re: [Libunwind-devel] Fast stack trace utility for Linux
Date: Mon, 6 Oct 2014 16:52:36 +0400

On Oct 4, 2014, at 6:08 PM, Milian Wolff <address@hidden> wrote:
> 
> this sounds very interesting. How does it compare speed-wise to local 
> unwinding?
> 

Local unwinding is special. For single-threaded programs we can access process'
memory and registers without overhead. In multi-threaded programs we need a way
to stop threads and get their registers. It implies using IPC mechanisms, so the
speed will degrade again.

I conducted simple tests tracing one thread of multithreaded program. Stack
contained 14 frames in 3 shared objects + 1 executable.

In the first test I took a code piece from libunwind man page and measured time
with RDTSC.

void show_backtrace (void)
{
  unw_cursor_t cursor; unw_context_t uc;
  unw_word_t ip, sp;

  unw_getcontext(&uc);
  unw_init_local(&cursor, &uc);
  while (unw_step(&cursor) > 0) {
    unw_get_reg(&cursor, UNW_REG_IP, &ip);
    unw_get_reg(&cursor, UNW_REG_SP, &sp);
  }
}

In the second test I put never-ending select() in that place. In third test
there was infinite loop. tbstack copied data and registers for only one thread.

Tracing the process several times I got numbers in following range:

1) 37-56 microseconds for local unwinding (183 on cold start);
2) 129-166 microseconds with thread sleeping in select();
3) 124-141 microseconds with spinning thread.


reply via email to

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