Jump to content

Recommended Posts

<Insert fancy Logo here :don14:>

 

Disclaimer: If you don't use unscheduled scripts or you don't know what "unscheduled" means this won't be useful for you. If you are a beginner in Scripting this is also likely nothing for you.

This is a tool aimed to help intermediate/advanced Programmers. Also No Battleye!

 

I'm proud to present the first public Intercept based mod!

I have a tiny script performance OCD so when I had the Idea about this last week I couldn't stop myself.

Arma Script Profiler is a mod that allows you to profile scripts in a way that wasn't possible like this before.

ASP replicates what the profiling binary already provides via it's diag_captureFrame commands but instead of only showing Engine Internals it shows Scripts.

In fact it is even using it's UI. Which sadly means that you also need to use the Profiling Binary to use ASP to it's full potential.

I wrote a full Wiki page explaining how to use it.

 

Edit: I've done lots of work lately to move away from the very limited ingame interface in the profiling build. The new version has it's own UI, doesn't need the profiling binary, displays more information, and can even profile over the Network. Read https://forums.bohemia.net/forums/topic/211626-arma-script-profiler/?do=findComment&comment=3298483 for more info.


Let me show you how it looks like instead of rambling on further.
Here is an example of what happens when you place a Vehicle in Zeus while using ACE and CBA:

arma3_2017-11-05_01-19-03.png

 

Let me explain what you are seeing here. If you ever used diag_captureFrame This Interface will be familiar to you.

 

Right at the top we have a graphical representation of the different Frames. The first row is always just the "total" bar which shows the total length of time that was captured.

Under that there are one or more rows for each Frame that was captured. In this example there is only one but there are ways to capture more than one.
This gives you a visual representation of when in the Frame a script was executed.

 

In the lower part of the window we come to the real meat of this. Here we have a Tree view of all "Scopes" that were executed that Frame.

The first element here is again the "total" time you can ignore it.
Next we have the first Frame.

 

There are 2 kinds of elements that can be displayed in the Tree. Scopes and Log messages.


The first scope inside that Frame is "ace_interact_menu_fnc_render". That is the Name of the Script function that the scope belongs to. You can choose the displayed Name yourself when you instrument your own Scripts.

Right next to that there are 2 "times".
    The first time shows the number of milliseconds since the start of the Capture/Frame.
    The second time shows how long everything inside that scope took to execute. Basically the runtime of that function.

    Both times are with nanosecond precision but I truncate them to 5 decimal places when writing to clipboard and the in-game UI truncates them again to 3 decimal places.

The next number is just the number of sub--elements of that scope. You can ignore it.

After that we have again the Name of the scope. I might add a way so you can define both names independently of each other in the future.

 

You can click on the Arrow to expand a Scope. Like I did with "CBA_xeh_fnc_init" in this example. That will show you which scopes are below that scope.
Essentially this gives you a full list of what functions your function called and how long each of them took.

At the Arrow you can see an example of a log message. This shows the output of a ACE TRACE macro.

You can use log message to print _this for example. So you can get a Calltrace of all your functions together with the arguments passed to the functions.

By using math and the "Time since start of frame" you can also calculate how much time was spent between 2 log messages. Log messages are precise to 2 microseconds.

 

 

 

This only works with unscheduled scripts. Because it measures the time between the start and end of a scope. And you can imagine how useless it would be if your scope starts and only ends several frames later.

 

 

To see all script commands added by ASP you can check the wiki but here are the most important ones:

createProfileScope is the heart of ASP. You use this to create your Scopes. It returns a custom Variable Type. You have to store the result in a private local variable!
When the variable goes out of scope, the scope is also ended. This is how ASP measures the time.

profilerCaptureFrame works just like diag_captureFrame.

It tells ASP to record from the start of the next frame till it's end and will then post the captured (A Capture is a frame that was recorded and is displayed. I will refer to it as Capture from now on) data into your Clipboard.
If you are using the Profiling Binary it will automatically open the UI and you have to press "PASTE ALL" on the bottom to paste the data and display it.

 

 

It is sometimes hard to find the Frame you are interested in. That's why ASP has the Trigger capture mode.

Using profilerCaptureTrigger you can start the Trigger mode. In this mode ASP will record every frame and look for a Trigger event. If a Frame contains a Trigger it will display it to you.
profilerTrigger is that trigger. If you call it while in Trigger mode the current frame will be captured.

Using this you can just place the trigger inside the script you want to profile. Then just start Trigger mode and wait till your script executes.

 

ASP was already successfully used to find and fix performance problems in ACE. And will most likely help prevent them in the future.

 

Currently ASP hooks into compile and compileFinal script commands and automatically adds a Scope to every compiled script. I will probably disable that in the Future.

But this way you can immediately start profiling all your scripts without having to instrument them before.

 

If you find some nice optimizations by using this please share :3

 

Download:

You can get the Mod here: https://github.com/dedmen/ArmaScriptProfiler/releases

 

This is still a bit experimental, I should really do a partial rewrite of the code. In case of Game crashes please PM me your crash report or crashdump files.

For bugs and feature requests please refer to the Github page.

 

This is also on Reddit!

I'm not really good in writing fancy forum posts. If someone wants to make this more splendid feel free to PM me.

Uploading this to Armaholic, withSix, Steam workshop or similar is not allowed! Please refer to the License.

  • Like 23

Share this post


Link to post
Share on other sites

Big update going on for the last few months. Didn't find time to report about it here.

The profiler got brofiler integration and is now WAY more powerful than just the ingame profiling view. With brofiler you also don't need profiling branch anymore to use it.

Here are a couple screenshots:

firefox_2018-06-23_21-48-57.png

 

arma3_x64_2018-06-23_21-50-25.png

 

As you can see in the tooltip. It also stores parameters passed to script functions so you can also use this to see what exactly happened in your code.

Brofiler can also profile over the network (By default TCP port 31313). Meaning now you can load the profiler mod on your Arma server. And just connect the Brofiler GUI to it over the network and profile the scripts on your server.

 

This stuff is still in "beta" but only because I'd like to make some performance improvements and maybe add some more features before a full release. For example in combination with my Debugger I might be able to add profiling of scheduled scripts too.
You can get it on the Profiler Github: https://github.com/dedmen/ArmaScriptProfiler/releases/tag/RC6

It uses a special version of Brofiler which is included in the download.

 

If you want to get REALLY crazy with it. The new Profiler also has integration of my SQF-Assembly mod. So you could profile your scripts down to every single SQF VM instruction or command call or variable assignment.

This is enabled by default I think. But this will generate huge amounts of data. You can disable it by just removing the sqf assembly plugin from the intercept folder.

  • Like 11

Share this post


Link to post
Share on other sites

So, could we load it on a linux arma 3 server and remotely profile it? I'd like see what the engine is doing every frame. because we often have huge performance drops down to ~3 FPS and it would be very interesting to know what the hell is going on.

Share this post


Link to post
Share on other sites
On 28.7.2018 at 6:46 PM, Sparker said:

So, could we load it on a linux arma 3 server and remotely profile it?

If I would compile my plugin for Linux then yes. :D Which I didn't try yet. Shouldn't be alot of work though.
 

 

On 28.7.2018 at 6:46 PM, Sparker said:

I'd like see what the engine is doing every frame. because we often have huge performance drops down to ~3 FPS

My profiler only profiles scripts. You might want Arma profiling build and use it's tools to create a dump of the frame onto the server. You can then pull the dump as a text file and copy-paste it into the dialog of the profiling build client.

Share this post


Link to post
Share on other sites

Thanks! You are very much right... I was looking for something like  the profiling build does actually.

Profiling, Performance, Arma Script Profiler, these things are so confusing!

Share this post


Link to post
Share on other sites

New big update is out.

 

On 1.8.2018 at 1:32 AM, Sparker said:

I was looking for something like  the profiling build does actually.

I can do that too now!

On 31.7.2018 at 10:06 AM, Dedmen said:

My profiler only profiles scripts.


Not anymoooore!

 

 

 

https://github.com/dedmen/ArmaScriptProfiler/releases/tag/1.0.28

with professional wiki page https://github.com/dedmen/ArmaScriptProfiler/wiki

Here are some example videos or screenshots:

 

https://cdn.discordapp.com/attachments/105464579600977920/537591450783842305/2019-01-23_12-14-56.mp4 A look at the default output, general script profiling.

https://cdn.discordapp.com/attachments/105464579600977920/537595406096400385/2019-01-23_12-31-30.mp4 A look at the most often called functions, live updating. With histogram for their runtimes

https://cdn.discordapp.com/attachments/105464579600977920/537730483748864016/2019-01-23_21-28-12.mp4  Profiling binary engine profiling now also visible!

Tracy_2019-01-23_13-11-46.png

Tracy_2019-01-23_12-22-17.png

 

 

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

Even though I'm still new to scripting I was already thinking of a tool like this and how useful it would be. THANK YOU so much. Great work. I'm following you on Github, impressive stuff!

 

Share this post


Link to post
Share on other sites

I also integrated profiling branch engine profiling into my profiler so you can now also do engine profiling in the UI.

Tracy_2019-02-11_12-13-23.png

 

I will push a new Release with all the latest bling bling today and I will update the wiki with new start parameters.

There will also be a Steam workshop release pushed today to make the Profiler more easily accessible for everyone.

ASP now also has support for remote engine profiling on a linux dedicated server.

 

I've spent the last couple days speeding up the mission start time with ACE/CBA by several seconds with the help of the latest iteration of my profiler. It has never been better before, and I hope I continue getting new ideas and will further improve it.

 

Steam Workshop: https://steamcommunity.com/sharedfiles/filedetails/?id=1652506957

Github Downloads: https://github.com/dedmen/ArmaScriptProfiler/releases

Wiki: https://github.com/dedmen/ArmaScriptProfiler/wiki

  • Like 5

Share this post


Link to post
Share on other sites

Just awesome. It was never that easy to debug and improve the performance of missions and functions, thank you very much!
One of the most useful tools for Arma right now.

  • Like 1

Share this post


Link to post
Share on other sites
On 2/13/2019 at 12:17 AM, auge103 said:

Just awesome. It was never that easy to debug and improve the performance of missions and functions, thank you very much!
One of the most useful tools for Arma right now.

I guess one of the left over problems considering missions is that it doesn't support scheduled scripts, which is what most mission makers use.

 

But these can only run for 3ms anyway and thus cannot drag down your perf really.

Because of that they are not high on my todo list. Certainly possible to implement that though, just didn't get to it yet.

You can still see what they are doing by implementing instruction level profiling, so that's enough of a workaround for me for now.

 

If anyone can bring up a sensible reason why he needs to be able to profile scheduled scripts then step forward.

 

On the up side... I think with engine profiling enabled you can even see the runtime of triggers in there. I should test that. There are tons of things I didn't test out yet, I only focused on profiling ACE/CBA/TFAR stuff so far.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×