Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memoro: no profile collected! #10

Open
JCBrouwer opened this issue Apr 24, 2020 · 1 comment
Open

Memoro: no profile collected! #10

JCBrouwer opened this issue Apr 24, 2020 · 1 comment

Comments

@JCBrouwer
Copy link

JCBrouwer commented Apr 24, 2020

Hello I'm trying to profile some caffe code.
I've built clang successfully and managed to compile my own code with it.

I've added -fsanitize=memoro to both my link flags and cxx flags in my CMakeLists.txt

SET(LINK_FLAGS "-L/usr/local/lib/ -lprotobuf -pthread -lpthread -lboost_system -fsanitize=memoro -Wl,--whole-archive ${CMAKE_BINARY_DIR}/caffe/lib/libcaffe-d.a -Wl,--no-whole-archive")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memoro -fno-omit-frame-pointer ${COMPILE_FLAGS}")

And am building as follows:

CC="../../memoro_compiler/build/bin/clang" CXX="../../memoro_compiler/build/bin/clang++" MEMORO_SYMBOLIZER_PATH="../../memoro_compiler/build/bin/llvm-symbolizer" cmake ..
make -j20 EdgeCaffeCore RunPipeline ModelSplitter py_edge_caffe

The build seems to run fine as does the compiled binary, however at the end of execution I just get

...
140644331943680 [0] -> Running task 1455 = 'Exec Task layer 21'
140644331943680 [0] -> Running task 1457 = 'Exec Task layer 22'
140644323550976 [1] -> Running task 1459 = 'Exec Task layer 23'
Waiting for workers to stop
78155 milliseconds
Memoro: no profile collected!

I believe I've followed all the steps in the documentation, how can I make sure memoro actually profiles my program?

The typefiles folder is made (but it's empty) and there are no .trace or .chunk files.
This is on Ubuntu 18.10 with clang version info:

clang version 8.0.0 (https://github.com/epfl-vlsc/clang.git 0dd61ad2e85d3a045692e791ff58b15331cb7c97) (https://github.com/epfl-vlsc/llvm.git 8456d158929b240756c396c4d5826b668c47435f)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/hans/code/edgecaffe/build/../../memoro_compiler/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
@JCBrouwer
Copy link
Author

I had a short email exchange with Treyer Thierry regarding this issue. His response:

Hello Hans,

Thanks a lot for checking out Memoro.
The project lacks some documentation and it seems to be where you're stuck at.

Based on the details from the issue you opened, your program seems to be instrumented by Memoro.
To profile your program, you need to run it with a couple of environment variables configuring Memoro.

First is the path to the symboliser that converts frame pointers to human readable stack traces.
You did set it during the compilation, but it is actually needed when you run your program.
MEMORO_SYMBOLIZER_PATH="../../memoro_compiler/build/bin/llvm-symbolizer"

Then, the options that configure Memoro's behaviour. The default is to run with Memoro disabled.
Here is a good starting point:
MEMORO_OPTIONS="register_allocs=1,register_multi_thread=0,access_sampling_rate=49"

register_allocs must be enabled to collect and keep track of all allocations made by the program.
register_multi_thread is only needed to know if an allocation is being accessed by multiple threads.

Finally access_sampling_rate sets how often Memoro registers loads/stores (above, it logs 1 load/store every 49th).
Intercepting every memory access introduces an important slowdown, so setting this value to a higher number let you reduce the overhead.
However, if you want to intercept every load/store, you can set it to 1.

After setting these two environment variables and running your program, you should see the .chunks and .trace appear.
You can load either in the visualiser and start exploring how memory is being allocated and used.

Let me know if this solves your issue!

This allowed me to collect profiles, however I still ran into issues with the visualizer. I sent the following reply with new issues, however did not receive a response. I did not follow up any more in favor of pursuing other avenues.

Thanks for your response, indeed setting the MEMORO_OPTIONS when running now generates the .trace & .chunks files. However, at the end of the run I get the error LLVMSymbolizer: error reading file: No such file or directory. On trying to open the files in the visualizer, "File > Open" stays on screen and the electron console prints Uncaught TypeError: Cannot read property 'updateData' of undefined. The exact command I'm running is MEMORO_SYMBOLIZER_PATH="../../memoro_compiler/build/bin/llvm-symbolizer" MEMORO_OPTIONS="register_allocs=1,register_multi_thread=0,access_sampling_rate=49" ./RunPipeline linear ../analysis/linear_memoro.csv and I've tried both with access_sampling_rate=49 and =1. Is there a way to better debug where Memoro related errors occur?

Also is there anywhere that lists all of the MEMERO_OPTIONS that are accepted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant