[PATCH] ldv/unwind: enable cache feature of libunwind

Masatake YAMATO yamato at redhat.com
Tue Nov 19 05:03:53 UTC 2013


I've submitted two patches to libunwind-devel:

    http://lists.gnu.org/archive/html/libunwind-devel/2013-11/msg00003.html
    http://lists.gnu.org/archive/html/libunwind-devel/2013-11/msg00004.html

The patch introduces the mechanism to cache /proc/$PID/maps to libunwind.

With patched libunwind:
% LD_LIBRARY_PATH=/usr/local/lib strace -e trace=open -o tmp  ./strace -k -o /dev/null ls  > /dev/null
% grep maps tmp | grep proc |wc -l
165

Without patched libunwind:
% grep maps tmp | grep proc |wc -l                                                                   
1251

About strace side following small patch is needed.

diff --git a/unwind.c b/unwind.c
index ed2d141..d620441 100644
--- a/unwind.c
+++ b/unwind.c
@@ -89,6 +89,7 @@ init_libunwind_ui(struct tcb *tcp)
        tcp->libunwind_ui = _UPT_create(tcp->pid);
        if (!tcp->libunwind_ui)
                die_out_of_memory();
+       _UPT_set_map_caching_policy(tcp->libunwind_ui, 1);
 }
 
 static void
@@ -137,6 +138,7 @@ build_mmap_cache(struct tcb *tcp)
        FILE *fp;
 
        unw_flush_cache (libunwind_as, 0, 0);
+       _UPT_flush_map_cache(tcp->libunwind_ui);
 
        sprintf(filename, "/proc/%d/maps", tcp->pid);
        fp = fopen(filename, "r");


Removing strace own mmap cache is the next step.

Masatake YAMATO


> On Tue, Nov 12, 2013 at 1:27 AM, Masatake YAMATO <yamato at redhat.com> wrote:
>> With turning on cache feature of libunwind, stack tracing
>> becomes two times faster(in my small test).
>>
> 
> Nice improvement.
> 
> With this patch applied it reads the maps file 1432 times:
> $ strace -e trace=open -o tmp   ./strace -k -o /dev/null ls
> $ grep maps tmp | grep proc |wc -l
> 1432
> 
> Without the patch:
> $ strace -e trace=open -o tmp   ./strace -k -o /dev/null ls
> $ grep maps tmp | grep proc |wc -l
> 1539
> 
> Luca
> 
> ------------------------------------------------------------------------------
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> _______________________________________________
> Strace-devel mailing list
> Strace-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel




More information about the Strace-devel mailing list