Background
I want to monitor for my ASP.NET Core 2.1 application which methods do the most allocation, and for this I wanted to use the LTTng events along with some other tools to help out. I have essentially tried following this guide: http://blogs.microsoft.co.il/sasha/2018/02/06/getting-stacks-for-lttng-events-with-net-core-on-linux/
(I have seen basically the same content in a few locations on the web, with very few/small variations. This article is one of the better formatted ones, but since its contents have been repeated by others, I have no reason to believe that it would be incorrect somehow.)
Setup
I am starting my server application with the command
COMPlus_EnableEventLog=1 /home/kqr/testserver/TestServer & >/dev/null
to run it quietly in the background. I then verify that it works by making a HTTP request and getting the response I expect.
Procedure
What I would like to do then is find out which methods do a lot of heap allocation, so I run the stackcount
tool from the BPF Compiler Collection (BCC) as such:
sudo stackcount-bpfcc -p 19010 -f \
/home/kqr/testserver/libcoreclr.so:EventXplatEnabledGCAllocationTick* \
> allocticks.stacks
I make a few requests that are supposed to be expensive in terms of memory usage, and then I cancel the stackcount command with Ctrl-C.
Problem
At this point, the allocticks.stacks
file is empty, as though there were no allocations during the time of recording.
I would have expected allocticks.stacks
to contain at least something.
What am I doing wrong?
Further Diagnostics
I also tried doing the same thing with perf, by first defining a probe for the GCAllocationTick events:
sudo perf probe -x /home/kqr/testserver/libcoreclr.so \
-a EventXplatEnabledGCAllocationTick*
then starting to record these events for the process:
sudo perf record -p 19010 -e probe_libcoreclr:* -g
again, performing some requests that I know are expensive in terms of memory usage, and then canceling the recording command with Ctrl-C.
When I then try to view the recorded data by running
sudo perf report -f
I get the following error:
Error: The perf.data file has no samples!
Ruled Out: Misspellings
At first I suspected that I had simply misspelled something. I therefore tried intentionally misspelling important identifiers in the commands but every time I did that, the tooling was very good at informing me that I was doing things wrong. Therefore, I have less reason to suspect that being the problem now.
Ruled Out: Missing Dependency
Similar to the misspelling case, I have tried intentionally uninstalling a dependency I know is required, and also then did the tooling warn me about that.
Ruled Out(?): Wrong libcoreclr.so
I am not quite sure how the whole .NET thing fits together, but I'm starting to think that maybe the TestServer
executable isn't using the libcoreclr.so
file in its working directory because it's using some system-wide binary. However, I haven't found any other file named libcoreclr.so
on the system, although I haven't looked very hard either.
I am, however, starting to think that maybe this is one of those self-contained deployment things and that the libcoreclr.so
is somehow embedded in the binary, so it doesn't have to rely on that as an external file. However, even if I run the application with
cd /home/kqr/testserver
COMPlus_EnableEventLog=1 dotnet TestServer.dll
I have the same problem, making me think that's a less likely cause as well.