sarbian

[1.1.2] GrumpyCollector 1.0.1 - Stutter ? What Stutter

Recommended Posts

20 minutes ago, sarbian said:

I would blame bad mod code. The coder in that thread clearly did not understand how Unity object works and that would not be an isolated case.

Fair enough.

  • Like 1

Share this post


Link to post
Share on other sites

Kerbal Space Program - 1.1.2.1260
OS: Windows 7 Service Pack 1 (6.1.7601) 64bit
CPU: Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz (4)
RAM: 8153
GPU: NVIDIA GeForce GTX 650 (1989MB)
SM: 30 (Direct3D 9.0c [nvd3dumx.dll 10.18.13.6472])
RT Formats: ARGB32, Depth, ARGBHalf, Shadowmap, RGB565, Default, ARGB2101010, DefaultHDR, ARGBFloat, RGFloat, RGHalf, RFloat, RHalf, R8

I done a test to see how shuttering it can be influence like improve or get worse base on GrumpyCollector, only 3 Mod are relevant in this test (inside game there are other to but at this point we not care about them :):

1. GrumpyCollector, 2. MemGraph,  3. KerboKatz with FPSLimiter & FPSViewer

Some small shuttering what it can be seen in movie they are influence by combo use KSP + OBS recording what i stop try to optimize because KSP it self :wink: but what is important to be seen it can be seen :cool: same anyone can do same & it will see result direct, what can be diferite depend by each PC hardware configuration :wink: . This is one place to see GrumpyCollector effect but for each sceane view, situation result it will be other ...

WARNING: For who expect to see something woow do not bother to watch, recording is done for testing reason!!!!

Thx for made greath tolls like this :wink:

Share this post


Link to post
Share on other sites
5 minutes ago, Blacks said:

Thx for made greath tolls like this :wink:

You should hit Alt+NumPadPlus a few times to change the scale of MemGraph so you can see the garbage collections... :wink:

Edit: but, nice vid...

Edited by Padishar

Share this post


Link to post
Share on other sites

Additional Info: Last weekend, after 1.12 release of RemoteTech i shot up 10 (4x kerbin, 3x mun, 3x minmus) sats.

All without a reboot/restart of OS or KSP. Some few with a "revert".

When i remind, some was going up really fast (i was swamped at that moments), some others dammed slow.

(All with green time stamp, low cpu/gpu workload and low RAM utilization, Debug console shows volative framerates, and NO warning or exceptions!)

Strange that one Launch have low fps and red Time stamp but goes up fast, others have yellow time stamp, but stutter and lag a lot.

Beside that, Mechjeb rarely gets crazy.. burn something wired and SAS begins to whip in all firections.

But that space science.. :P

Share this post


Link to post
Share on other sites
2 hours ago, Blacks said:

Thx for made greath tolls like this :wink:

In the VAB it appears that a large part of the memory allocation is caused by the UI that displays the parts on the left.  This appears to use some rather non-optimal LINQ queries that result in large amounts of garbage, the more parts being displayed the more memory is allocated.  In a stock game the extra allocation over sitting in KSC varies from approx. 400 KB/s for the smallest part group (command and control) to over 5 MB/s for the largest (utility).  Having lots of part mods installed generally increases the size of the categories so increases the VAB garbage thrash.  Squad are already aware of this and, hopefully, it will be fixed fairly soon.  It shouldn't be too difficult to translate LINQ code into something more garbage friendly.

  • Like 3

Share this post


Link to post
Share on other sites
4 minutes ago, Padishar said:

In the VAB it appears that a large part of the memory allocation is caused by the UI that displays the parts on the left.  This appears to use some rather non-optimal LINQ queries that result in large amounts of garbage, the more parts being displayed the more memory is allocated.  In a stock game the extra allocation over sitting in KSC varies from approx. 400 KB/s for the smallest part group (command and control) to over 5 MB/s for the largest (utility).  Having lots of part mods installed generally increases the size of the categories so increases the VAB garbage thrash.  Squad are already aware of this and, hopefully, it will be fixed fairly soon.  It shouldn't be too difficult to translate LINQ code into something more garbage friendly.

Agreed, i say from beginning there are other mod inside of game & i done this intentional to see how game & grumpy +rest of mods work together or how game it handle in stress situation. Result or how game behave it variate depend by each situation, probabil i can spam with recording, but much more important i think is to recive more feedback from many other ... special this can help to make a small step in optimize, cough, cough, game :) (looking innocent around cough & whistle)

Small question: game by default what value it suppose to have with Grumpy ?

anyway if is anything what can be done from my side yell & i will see

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

Just guessin, but, can this garbage collector (the stock one) to cause the random CTD inside the editor?

Share this post


Link to post
Share on other sites
3 minutes ago, Nansuchao said:

Just guessin, but, can this garbage collector (the stock one) to cause the random CTD inside the editor?

There is only one GC, this mod just calls it manually at regular intervals rather than letting Mono decide when to call it.  The CTDs are very unlikely to be anything to do with the GC unless Unity have been making changes to it without telling anyone.  The cause is much more likely to be a multi-threading related issue, especially as they seem to happen most frequently when in the VAB where the Unity engine does more processing in background threads (for some unknown reason).

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the explanation. Is there a way to see what KSP really does in background while in the editor?

Share this post


Link to post
Share on other sites

You may be able to using the Unity profiler and/or a debug version of the player but if that was the case then I would have expected someone to have done so by now as the raised CPU usage in the VAB has been reported numerous times...

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, sarbian said:

To be precise Unity uses the Boehm GC. So if you have some magical trick to make it work please enlighten those who have been looking into it for month. 

 

Have you tracked down which part of the code is taking too long? if so can you mail me a sample and I'll see if I see anything wrong with it.  

The only real thing you can do is make sure that you are not releasing lots of objects all at once, clean up and make everything as temporary as possible. As i've not seen the source code for ksp, but looking at the git hub repositories for mods, I see a LOT of static lists, these are very bad for the garbage collector as it has to check everything that might have a reference to the object. 

If you are using VS2015 add the code guidance packages to the source (one at a time, it's a nightmare to do in one go!)  

*nuget* 

Microsoft.AnalyzerPowerPack

codecracker.CSharp

They will point out problems in the code, I still miss some when I'm coding and I've been doing c# since the first beta. 

I like to use the StyleCop.Analyzers as well, but my colleagues would kill me if I inforced it :).

Share this post


Link to post
Share on other sites
11 minutes ago, genericeventhandler said:

Have you tracked down which part of the code is taking too long? if so can you mail me a sample and I'll see if I see anything wrong with it.

I have years of experience in Java performance analysis. I can optimize my code fine, thanks. And I have the whole JetBrain suite so I am fine dont worry.

But once more : most of the technique or analysis used for modern C# are worthless when used with Unity. The old mono is full of "stupid" ways of doing things and you have garbage generated where no modern analysis tool would tell you (i.e. a modern mono/.NET reuse a single StringBuilder for concat/format. The old Unity mono does not).

Share this post


Link to post
Share on other sites

Thanks for giving this a go.

 I don't suffer stutter but there are loads of people who do, personally I suspect that interaction with a third party program on their machines or some OS component means GC just takes longer no matter how much garbage is collected so there will not likely be a fix for them. Increasing the frequency of GC would just increase the frequency of stutter in that case.

Anyway, yet again I am impressed by your contribution to the community. KSP would be much less without you.

Share this post


Link to post
Share on other sites
17 hours ago, Blacks said:

Small question: game by default what value it suppose to have with Grumpy ?

Do you mean "what value in the Grumpy dialog corresponds to KSP default behaviour"?  If so, then it doesn't work that way.  The game normally doesn't manually call the garbage collector on any kind of schedule, it just lets Mono run it automatically when the heap fills up.  This mod always calls it at the interval specified in the dialog whether the dialog is open or closed.  It would probably be helpful to be able to toggle it off completely rather than requiring removal of the mod.  I may send a PR to sarbian later if I get a few minutes...

Share this post


Link to post
Share on other sites
On 10/5/2016 at 11:04 PM, sarbian said:

This is an experiment. Some people keep complaining about stutter in the game and other don't get this problem. This addon is for the first category.

If you have stutter in gamer please install this and tell us if things are better or worse. You even have a amazing UI that you can open with Ctrl + * (the one on the numpad). Faster may lower stutter but also lower the frame rate. Slower may make the stutter come back but has less impact on the frame rate.

Please share your experience with using this and if it make the stutter better or worse.

GrumpyCollector-1.0.1.0.zip

License MIT

Source

 

It's nice what you tried to do, in my personal case it makes it worse. Thanks for your effort!!

Share this post


Link to post
Share on other sites
19 hours ago, Padishar said:

It would probably be helpful to be able to toggle it off completely rather than requiring removal of the mod.  I may send a PR to sarbian later if I get a few minutes...

I have now sent a PR that ties the running of the GC to whether the window is shown and also has a considerably modified UI to reduce the garbage creation to a minimum (no buttons in the dialog, now uses Ctrl-NumPadPlus and Ctrl-NumPadMinus to change the rate).

Edit: I tweaked the PR late last night to have a separate toggle for the collection on Ctrl-NumPadDivide so you can have it running with the UI closed.

Edited by Padishar
  • Like 2

Share this post


Link to post
Share on other sites
On 5/12/2016 at 2:49 AM, John FX said:

Anyway, yet again I am impressed by your contribution to the community. KSP would be much less without you.

This, oh so much this.

Share this post


Link to post
Share on other sites

@sarbian I experienced some stuttering, but I'm used to it and it doesn't bother me. The mod doesn't help with that, but setting the interval to 10s helped with the random VAB crashes I've been experiencing since the 1.1 update, which seems to be GC related. This bug.

I noticed how right before the crashes there was a short pause. No crash report and nothing on the logs, but sometimes I'd get a memory related error on the terminal, like *** Error in `./KSP.x86_64': double free or corruption (out): 0x00007f83328ef200 ***. I think there's something wrong happening if the GC cycle runs while you are removing a part that has staging, and setting a long interval makes that more unlikely.

Share this post


Link to post
Share on other sites

This experiment may have failed but I learned a lot just reading this thread so thanks for that!

Share this post


Link to post
Share on other sites
3 hours ago, lodestar said:

@sarbian I experienced some stuttering, but I'm used to it and it doesn't bother me. The mod doesn't help with that, but setting the interval to 10s helped with the random VAB crashes I've been experiencing since the 1.1 update, which seems to be GC related. This bug.

I noticed how right before the crashes there was a short pause. No crash report and nothing on the logs, but sometimes I'd get a memory related error on the terminal, like *** Error in `./KSP.x86_64': double free or corruption (out): 0x00007f83328ef200 ***. I think there's something wrong happening if the GC cycle runs while you are removing a part that has staging, and setting a long interval makes that more unlikely.

Same here. Stuttering isn't better but VAB crashes less.

Share this post


Link to post
Share on other sites
3 hours ago, lodestar said:

and setting a long interval makes that more unlikely.

That isn't how this mod works.  This mod only increases the calling of the garbage collector, it forces a collection at the specified interval but, if lots of garbage is being created then the collections will still be run by Mono automatically.  E.g. if, without the mod, the collections are happening every 4 seconds and you have the mod set to every 10 seconds then the heap will fill up and be collected after 8 seconds.  After 10 seconds the mod will run another collection (which will only have 2 seconds worth of garbage to collect).  Then it will take another 8 seconds to fill up again and then after another 2 seconds the mod will run it again.

While it would be very nice if this did directly affect the random crashes, the nature of random crashes (especially ones that appear to be multi-threading related) is such that any change in internal program behaviour can have a significant effect.  Two people with subjective reports are certainly not statistically relevant so please don't do anything that will flood this thread with people looking for a fix for the crashes.

  • Like 1

Share this post


Link to post
Share on other sites

This entire topic isn't "statistically relevant" because the OP asks for subjective reports. :D

 

Share this post


Link to post
Share on other sites

having problems getting the GUI to pop up, but the stuttering is worse for me, uniform in timescale, but worse

Share this post


Link to post
Share on other sites

A suggestion for all who want to report how Grumpy affect game functionality:
1. Step 1. Find KSP.log
2. Step 2. Open KSP log, then select first part of log were is report PC configuration Copy & Paste on beginning of your post it suppose to be most important information with all need to start
Example:

Kerbal Space Program - 1.1.2.1260 (WindowsPlayer)

OS: Windows 7 Service Pack 1 (6.1.7601) 64bit
CPU: Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz (4)
RAM: 8153
GPU: NVIDIA GeForce GTX 650 (1989MB)
SM: 30 (Direct3D 9.0c [nvd3dumx.dll 10.18.13.6472])
RT Formats: ARGB32, Depth, ARGBHalf, Shadowmap, RGB565, Default, ARGB2101010, DefaultHDR, ARGBFloat, RGFloat, RGHalf, RFloat, RHalf, R8

3. Step 3. When you will make test changing value of > grumpy < do it in various condition not only in VAB or SPH, what i did was just a example or just a small part of experiment to show how game it react when mod it use (i say already result can variate depend by each PC hardware configuration, system operation, number of mods use, error & exception what my be run behind ....)
4. Step 4. When you say "is worse" or "is better" bring more info to like "is worse if i set to 0.250" or "is better if i set to 10"... flying, loading a stock craft, or 100 custom craft or doing nothing ... is important to let to know in what condition you experience that
5. Step 5. I am tent to say posting log it will be good to, but at list if report it will have PC Configuration add, more details describe it will be fine, but it depend by experiment it self how deep it want to goo :wink:

Cheers

Edited by Blacks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now