4

In one of my Nim projects I'm having performance issues. I'm now trying to use nimprof to see what's going on. I have an import nimprof in my main source file, and I'm compiling with --profiler:on. When I run the program I can see the messages:

writing profile_results.txt...
... done

However, profile_results.txt only contains this:

total executions of each stack trace:
Entry: 1/1 Calls: 2741/2741 = 1.0e+02% [sum: 2741; 2741/2741 = 1.0e+02%]

The run time was about 1 minute -- so I don't think it is just not enough time to sample anything. Is there any way to get something more meaningful out of nimprof?

bluenote10
  • 23,414
  • 14
  • 122
  • 178
  • 2
    Not sure about nimprof, but I always used valgrind and kcachegrind and got good results for Nim programs. – def- Jul 25 '15 at 08:18

2 Answers2

4

You need to add the compiler flag --stackTrace:on, or there won't be any function names or line numbers to analyze.

ratiotile
  • 973
  • 8
  • 16
2

1.0e+02% is just a silly way to say 100%. It says it took a lot of stack samples and they were all the same, which is not surprising.

What you need is to actually see the sample. It should appear below the line above. It will show you what the problem is.

Just as an aside, it should show line numbers as well as function names, and it shouldn't just sort the stacks by frequency. The reason is there could easily be a guilty line of code that is on a large fraction of stacks, even though the stacks are otherwise different, so if the stacks are sorted, that line will not be aggregated.

Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135
  • 1
    In this case my question becomes: How can I see the sample? What I have copy/pasted above is all I can see in the `profile_results.txt` file. There are no line numbers or function names. – bluenote10 Jul 25 '15 at 13:23
  • 1
    @blue: It sounds like there may be a bug in the profiler code that prevents it from showing the sample. So if you run it under a debugger, it should be possible to fix it. Of course, if you're under a debugger, all you have to do is interrupt it and display the stack. – Mike Dunlavey Jul 25 '15 at 13:28