pprof + "redis-server --loadmodule ./build/libmymodule.so"

40 views
Skip to first unread message

Zongheng Yang

unread,
Jan 6, 2018, 7:22:47 PM1/6/18
to Redis DB
Hi all,

Has anyone tried using pprof [0] to profile a redis-server, loaded with a custom module?

Here's how I launched the binary:

     $ CPUPROFILE=/tmp/prof.out redis/src/redis-server --loadmodule ./build/libmymodule.so

After this is set up, I launched commands, and shut down the server.  Then,

     $ ~/bin/pprof -tree redis/src/redis-server /tmp/prof.out

*does* print out the analyzed profile, but without any symbols, an except is here (https://pastebin.com/EUtzdfAm):

    flat  flat%   sum%        cum   cum%   calls calls% + context
----------------------------------------------------------+-------------
                                             1.80s 39.91% |   <unknown>
                                             1.16s 25.72% |   [libtcmalloc.4.dylib]
                                             0.59s 13.08% |   [libmember.so]
                                             0.40s  8.87% |   [redis-server]
                                             0.23s  5.10% |   [libprofiler.0.dylib]
                                             0.21s  4.66% |   [libc++.1.dylib]
     4.51s 92.61% 92.61%      4.51s 92.61%                | [libsystem_kernel.dylib]

where libmember.so is my custom module.  The libmember.so library is built in the following way:

  set(REDIS_MODULE_CFLAGS -W -Wall -dynamic -fno-common -g -ggdb -std=c++11 -O2)
  set(REDIS_MODULE_LDFLAGS "-undefined dynamic_lookup")
  set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
  add_library(member SHARED member.cc)
  target_compile_options(member PUBLIC ${REDIS_MODULE_CFLAGS} -fPIC)
  target_link_libraries(member profiler)
  target_link_libraries(member tcmalloc)

My question: how do I change the compilation / linking, so that symbolization works?


Thanks,
Zongheng

Dvir Volk

unread,
Jan 17, 2018, 4:59:50 AM1/17/18
to redi...@googlegroups.com
Hi.
A few things to try:
1. Try --add_lib=/path/to/your/lib.so
2. If that doesn't work, try stating your module and not redis-server as the executable. 

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Zongheng Yang

unread,
Jan 17, 2018, 2:24:42 PM1/17/18
to redi...@googlegroups.com
Hi Dvir,

Do you mean to supply --add_lib to "pprof", or to "redis-server"?

You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/3NjGznXYSy4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.

Dvir Volk

unread,
Jan 17, 2018, 4:11:56 PM1/17/18
to redi...@googlegroups.com
To pprof. If you module is linked with -lprofiler and you object files are compiled with -g -ggdb is works.

I did however have to add explicit calls in my C code to start profiling, it didn't generate anything meaningful if I didn't.

Zongheng Yang

unread,
Jan 18, 2018, 7:15:31 PM1/18/18
to redi...@googlegroups.com
I'm using this version of pprof (https://github.com/google/pprof), and it doesn't have an --add_lib argument.

I also tried adding ProfilerStart(..) in my custom module; same issue.

One thing to check though: you said "my C code", was your setup the same as mine (launch redis-server with a custom_module.so)?  Did you have to compile antirez/redis differently (I just did `make`, no other options)? 

Zongheng Yang

unread,
Jan 18, 2018, 7:19:45 PM1/18/18
to redi...@googlegroups.com
Dvir,

If you were using the same or sufficiently similar setup, it'd be great if you can paste your workflow.  Thanks! 

Dvir Volk

unread,
Jan 19, 2018, 1:14:50 AM1/19/18
to redi...@googlegroups.com

Same as yours. -lprofiler on the linker, redis compiled normally, my module compiled with debug symbols CPUPROFILE set, nothing else.

Zongheng Yang

unread,
Jan 19, 2018, 5:34:54 PM1/19/18
to redi...@googlegroups.com
Thanks.  I did not get this to work on Mac, but succeeded on an Ubuntu box.
Reply all
Reply to author
Forward
0 new messages