Hello, everyone.
And now we have a talk by Johannes Bergberg, I hope you pronounce that right, is a JVM
developer working on profiles and the underlying technology, it currently works on the GAP,
modeling documentation, smaller utilities, and the Firefox profiler.
It's going to have a talk on Firefox profilers beyond the web, using Firefox profiler to
view Java profiling data, and yes.
Yeah, thanks for the kind introduction, yes, I'm Johannes Bergberg, I'm working at the
sub machine team at SAP, we create the best JDK, so just download it, but I'm here because
I worked on the Firefox profiler in the recent months, and yeah, I'm going to start now,
because when I'm telling people that I'm like working at SAP at Firefox profilers,
they first start me two questions, like first, wait, SAP does open source?
Yes, SAP does open source, and quite a lot, for example, here at sub machine, my team
we're working on the open JDK, for example, if you've ever used JDK 17, we have the JDK
17 maintainer in our team, so we do many nice projects in this field, SAP also works with
the Eclipse Foundation or other parts, so yeah, we're doing quite a bit of open source,
but how did I end up here talking to you in this Mozilla death room as a JDK developer,
which normally doesn't happen, so I had a problem, I had a project on debugging last
year, so what I wanted to do essentially is that I had on the one hand my IDE, and on
the other hand the JVM, they wanted to improve the protocol in between, so I had then some
test cases and some of these, some integration testing, for example, here they parsed some
program and I did something with it, and I wanted to see why it was slower than I expected,
and so what I wanted to do is just write plug on my IDE, tell it that, hey, profile it and
show me the profile, and that's all, and I wanted to do it with open source source, because
I like open source and that our team open source is really key, so I didn't find anything,
but I found some tools that got into this direction, so essentially there were tools
that produced some flame troughs, STUI, and Mario Fusco set a few days back, a lot of
frame graphs, when you do something stupid it punches you in your face and it's impossible
not to see it, so that's great, you can use flame troughs for a lot of things, but sometimes
they are not enough, so when you regard visualizations you have those easy tools that are easy to
use, but don't have that many features, and on the other hand you have the big tool, it's
called JMC, there's lots of features, but has a quite steep learning curve, so I had
to write my own, because I wanted to have something with more visualizations than just
flame troughs, but that was usable, also usable to the end user, and not just the OpenJD
developer like JMC is, quite frankly, and I wanted to just right click on a method,
on the test method, and just tell my IDE, hey, run the thing, so I don't end up writing
so much code and boilerplate, so writing your own intelligent plugin, and that's the IDE
I'm targeting, but it's quite the same for all the IDEs too, like visual studio code,
is quite simple, you can just download some templates and work on them, so this I did
like in August in like half a week, but then it came to visualization options, so I looked
around and thought, maybe creating my own visualizations like flame troughs and so on,
but this turned out to be cumbersome, and really would take a lot of work, so I looked
around for web-based visualizations, because you can just embed a web-based profiling view
into your IDE, because for example in Telstra you have a chromium, an embedded chromium,
and in VS code it's essentially a browser anyway, so that's no problem, iPhone speed
scope, which is quite nice, but the problem is it doesn't show anything other than stack
traces and some profile timing information, and I wanted to show more, there is kind of
an existing plugin for IntelliJ, but that only shows flame grouse, and so we're back
to step one, and then I found Firefox profile, and this is how I ended up here, so essentially
Firefox profile is this large application that you've probably seen in some other talks
today too, this is actually taken from a previous talk, because I was too lazy to run Firefox
profile, directly you see here it's like it does everything, and it's quite cool, and
one of the many advantages is that it's developed by a small team that answer even stupid questions
in a matrix channel, so check it out if you have some questions, and they were open to
working with me on my project, and also it's backed by cooperation, it's backed by Mozilla,
which is quite cool, because it's not a one-man project like other tools are, and so what did
I do to integrate it, and what might you do if you want to also use Firefox profile,
it essentially points down to creating a converted to my data format, it's the JFR file format
to the Firefox profile format, and then you put it in the server, because Firefox profile
likes it when you can just say take this file from a URL, so you put it in the server, that's
fine, for me I created a travel in server, then you can just wrap it in IntelliJ plugin
or use code plugin or zone, and then I took the Firefox profile UI, you can use profile.firefox.com,
but you would typically just host it your own, because Daniel Burke's in demos like
Bolly today, when I have time, and you can control all the changes that come into your
Firefox profile UI, and also you can use a modified version, which I did to put all
my progress that is still out there and not merged into one version, so the things you
later see, that the inmate will sometimes not yet in the mainstream Firefox profile,
so shortly to the file format, so file format is quite simple, it's just a chasing file,
and this is zipped, and it has some metadata information like the name, the interval, some
settings, and then you have the stretch information, so for every thread you have a separate section
in the profile file, and you have a list of samples there, and this list contains essentially
the time of when the sample is taken, the stack, and the CPU delta that elapsed the
CPU time since the last sample, so it can be used to show the CPU usage data, then the
stack is not all the stack, but it's an index into the stack area, and this contains like
the list of stacks, and where the stack is just a frame appointed to the previous stack,
like the top frame, and then the previous stack, so it points back, and then the category,
and of course the frame is an index into the frame area, and that contains the functional
line, so what you need for a frame, and then of course function is not really the function,
but it's an index into the functions area, and you get the point here, because name and
file are of course not strings, but they are indexes into the string table, that's quite
hard to debug sometimes, and I had many struggles with it, but it's quite performant, and it's
easy for the frontend to see, so after I explain to you how I did it, here's the plugin, I
call the Java JVR profile plugin, you can find it in the track branch marketplace on
GitHub, it's open source, it's MIT license, I believe, and it works because JVR was open
sourced with JDK 11, so it's all open source, just try it out, so how can you get it, just
open your IDE, and go into the plugin install, view and type in Java JVR profile, and you
get it, then you get some nice buttons, when you right click, and you can just click on
the profile with JVR, then you profile it, and then here's a simple example application
that just computes kind of complicated, a few nuchin number or something like that,
and then you can see that it executes the program with some JVR-related options to
profile it, and then it automatically the profile of JVR-file, you get the call tree,
you can also look at how every frame is like executed, whether it's in interpreted mode
or in our JIT compile, then you can double click and jump back to the IDE, so it has
basic IDE integrations, and you can shift double click and see the source view that was presented
in the previous talk shortly, so you can see here that in this code, the recursive call
is called the most, it's found the most time in the static calls, and then you can have
a function table which lists all the methods combined, so from all the stack traces and
you see what method is used the most, that's not yet in the mainline Firefox Profiler,
you can have some flame crafts, and you can have some nice tooltips, and you can get some
information on the profile, you can even upload it like a normal Firefox profile, so you can
share these profiles and view them in a normal profile at Firefox.com, just with some few
features, and then we can also open any JVR-file, and JVR is like the default, like the de facto
standard for profiling files in Java, and you can see here that we get also some crafts
that show us the CPU load and give us some summary on GC, like how much memory it requested,
and what's also cool, we can not only see timing, but we can also see call tree for
other things, like for Java error, for thread starts, where did they happen, or for object
allocation, and when you get to Java error, you see that this code uses error to create
error every time, like probably the parsing fails, so we can also see, as the last part,
the market chart, so we can get all the events that the JVM remits, so for example, we see
here at the top, that we had a drop in the memory that the heap was large, and we investigated,
we could zoom in and see, okay, that's probably because here GC happened, and this GC took
like 10 milliseconds, and this is quite nice because you can then investigate, have the
call tree as a simple thing, and then later drop in and go deep dive into the data, and
if you know Async Profile, it also supports Async Profile, and also when you want to create
the profile, you can decide where you want JVR to build in for the JDK or Async Profile,
and that's all, but I think I still have some time, so I hope this works, because I can
tell you a lot that it might work, and we can show you some screens, but here is the
actual working, hopefully working prototype, so just right click on the main method, tell
it Profile with JVR, and then it tells you, hey, I profiled it, then it opens the profile,
and then you can just look at it, zoom around, and see that you have to select the main JVR,
you can jump back to the source code, you can shift, double click, and everything, and
the cool thing is you can even open, as I showed you, arbitrary JVR files, they shouldn't
be too large, because then my program runs out of memory sometimes, it's still a prototype,
so try it if you want, I would be happy to have any feedback, go to the issue pages,
and eventually you find this plug-in, as I said, in the chat print marketplace, you
find me on Mastodon, on Twitter, and on GitHub, but you also find the subprojects, so you
can use parts of this project, like only the converter, and only the JVR to Firefox Profile
server, you find more information on my tool, and also a background information to this
talk, in two blog posts on my blog, and you can find the submachine team at Sweet Submachine
at Twitter, and find out about our great projects at Submachine.io, that's for me, thanks.
Thank you very much, and we have quite a bit of time for questions, so...
Thank you.
Have you received any feedback from users about this tool, like some colleagues or...?
Yes, good questions, yeah, I received quite some feedback on Twitter, they were quite
happy, I did some internal... I showed it internally at SAP, to some colleagues, and
they were quite happy, I also showed it to friends of mine, and also it was quite great.
It still has, of course, problems, because it's a prototype, not everything might work,
but yeah, I'm looking forward, so just give it a try, it's free, it's open source, open
some issues on GitHub, if you like, so yeah.
I will steal the mic.
Did you add to forward some patches upstream to make it work in the first place?
Yes, a lot, so for example...
Because you mean they have bugs, or you need to adjust it for the...
There for example, this feature here is not yet in Master, but for example, what I added
was, you saw this, this, you saw this here, this, the listing of the categories, this
is something that I added, and I added pull requests for the function table, which is
not yet in because it's far more work, I added some resizing and searching, that's yet, that's
I think in, so I added some pull requests that are in, but not all of them, but I hope
I get it in in the next few months.
You can give beer to the upstream developers that are here to get the patch.
Yeah, but I fixed all the bugs that they wanted to be fixed, so I think we're working
more like colleagues.
I will ask a follow-up question quickly.
Did you have to do anything Java specific in that case?
There's nothing that is real on Java specific, so the only the converters like Java specific
because it takes Java data and processes it, but anything else in the UI is generic.
I was wondering if this could be useful to profile Java applications that run native
code and the other way around, and how would that work?
Speaking of, for example, Firefox 400, I don't think we have a lot of insight into the performance
of our Java code, and that would be useful to have.
So, it's in some ways where they can work with chain I or something like that.
I think asking profile is a quite nice profile that I also support, and this gives you information
on native, on native phrases, and I'm working on getting a profiling API into OpenJK that
improves this a lot, but if you want to know more about the struggles, come tomorrow to
my talk in the Fuji room, they hear enough about this topic.
Hi.
Yeah, thanks for the presentation, very impressive.
The question I had, actually, I have two questions.
The first one is, what is about Firefox profiler that made you choose it, I suppose, and then
the second question is, do you see the potential for maybe a tool like this to have a web-based
editor?
Yes, the first thing, why did I choose it?
Because it's a nice project and I didn't want to write everything on my own, and it contained
lots of the features that I already wanted, so, yeah, and they could ask questions, because
when you're working alone on such a prototype is that you don't get any feedback.
Here I got a lot of feedback on progress, and it was a quite good learning experience.
The other thing is, yeah, as I said, the project consists only of a tiny intelligent
wrapper around the other code, and this can be used to just integrate it into your Spring
web app to directly show it in the web.
I have some ideas on this, just follow my blog to know more about this, or my Twitter
almost.
So do you think about the upload local profile?
Is this an important feature in your opinion?
Is it something that you'll, is it part of the features that made you choose Firefox
profile?
Yeah, it's quite a great feature, because you can essentially, in open source, you could
later than just tell other people, I have some performance issue here, for example,
for issues.
It's essentially the same thing Mozilla does, and I hope I can open it to use it in a corporate
setting, for example, adding features to use Microsoft Thrive for it, so it's more safe,
because currently you're uploading it into the web, and that's not that great when you're
doing internal company stuff.
But this feature then could really make it easy for people to just say, hey, here I have
some problem, give me your stack trace, just upload it, and you're fine.
So maybe next feature could be a server, and make it configure.
The problem is, it's just me currently working on it, and so it's just a prototype, I have
to see what could be implemented in the future.
Any other questions?
We still have three minutes, so if you have questions, we can take them.
Thank you very much, do you want to add anything else?
Just try it out, I would like to have some users, because I want to know what features
are important to you, and also where you find some problems, for example, someone found
that the Microsoft support wasn't there, so on Microsoft it just crashed, on Windows,
so if you find any issues, please drop by, and come to the Matrix channel of the Firefox
profile, there you can find me sitting around all day, and can also answer questions directly
on it.
Thank you very much.