plasma-umass / coz

Coz: Causal Profiling
Other
4.05k stars 160 forks source link

Coz just outputs two lines per benchmark #109

Closed kstrafe closed 4 years ago

kstrafe commented 5 years ago

I run make bench inside the benchmarks/kmeans directory and get just this in profile.coz:

startup time=1568731888530442258
runtime time=1000760853

I don't think I can do anything with this, and the guide says I need to do multiple runs, so I did (300 runs), and each run just adds two lines like that and nothing more.

This is on Manjaro 18.1.0, kernel 5.3.0-1, using GCC v9.1.0, as well as GCC v8.3.0, with the latest libelfin/libdwarf from github (ref ac45a09).

Is it supposed to output just this? What do I do with this?

emeryberger commented 5 years ago

Nope. It sounds like the progress points are not being executed / built for some reason.

philipc commented 4 years ago

I'm seeing the same issue, and it looks like the problem is that get_loaded_files doesn't account for the executable segment offset of 0x1000, which you can see with readelf -l:

  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000001000 0x0000000000001000 0x0000000000001000
                 0x0000000000000fbd 0x0000000000000fbd  R E    0x1000

If I add this hack then it works better:

@@ -246,7 +246,7 @@ unordered_map<string, uintptr_t> get_loaded_files() {

     // If this is an executable mapping of an absolute path, include it
     if(perms[2] == 'x' && path[0] == '/') {
-      result[path] = base;
+      result[path] = base - 0x1000;
     }
   }

It looks like this is running in the process being profiled, so maybe it should use dl_iterate_phdr instead of /proc/self/maps? Although there is an issue to run in a separate process: #60

ccurtsinger commented 4 years ago

Hopefully #132 fixes this issue. My development environment does not produce executables that are loaded with an offset, so I have not been able to test that case. If you could check it (or describe how you produced such an executable) I'd appreciate it.

I used to use dl_iterate_phdr, but switched away because of some issue I have now completely forgotten. That may be more reliable so I'll give it a try at some point.

jesperpedersen commented 4 years ago

I'm getting

startup time=1570549817515318671
runtime time=13227434985
samples location=/path/to/binary/location:408  count=1
samples location=/path/to/binary/location:841  count=1

now.

Using Fedora 30, user can perf record, app is compiled with gcc -gdwarf-4 and contains two COZ_BEGIN/COZ_END pairs. Each of the pairs should have been hit ~2900 times during the test.

philipc commented 4 years ago

I was using clang version 6.0.0-1ubuntu2, and #132 fixes it for that.

It still doesn't work if I use clang version 8.0.1-svn363027-1~exp1~20190611211629.77, and the problem looks similar to what @jesperpedersen reports. I haven't tried to figure out what's different.

jesperpedersen commented 4 years ago

Turns out that libelfin 0.3 doesn't work; line_info.file->path is empty. Either use master branch, which has the fix (https://github.com/aclements/libelfin/commit/4a678c782847ac2db3a1c1790b1b666f804d1d4f) or the 0.2 release.

jesperpedersen commented 4 years ago

I think this issue can be closed unless a note should be added to the README.md file regarding the libelfin issue

ccurtsinger commented 4 years ago

Thanks for the diligent debugging!