[BUSTED] Making an ultra light Tick() in ZScript

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

[BUSTED] Making an ultra light Tick() in ZScript

Postby Nash » Thu Feb 08, 2018 2:35 am

EDIT: Seems I was completely wrong. Doing this actually degrades performance even worse - I suppose simply having a Tick override adds to the CPU overhead. I tested this by sticking an empty Tick() override and I get worse performance. The think time exploded from 1 - 2 ms to 10++ ms. So if anyone thought they could get smart and do this... well, forget it.

+NOINTERACTION and a regular Tick() is still the best way to get fast, non-interactive decorations in the map. Remember, as soon as you provide a Tick override, the CPU cost will shoot up.

Still including original post for educational purposes.

Spoiler:


(All measuring is done with stat think)
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby gwHero » Thu Feb 08, 2018 8:50 am

What do you mean by a 'regular' Tick()? Having no override and no extra code?
User avatar
gwHero
Be your own Siddhartha
 
Joined: 08 May 2017
Location: The Netherlands

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby krokots » Thu Feb 08, 2018 10:52 am

How much Tick overrides will actually produce some visible lag? I've only did this with my 1000 vs 1000 pinkies battles, and inside Tick override, every one had Actor Iterator within another Actor Iterator. Just then I got definite lags, but it was still very much playable.
krokots
 
Joined: 19 Jan 2010

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Nash » Thu Feb 08, 2018 1:23 pm

gwHero wrote:What do you mean by a 'regular' Tick()? Having no override and no extra code?


I mean, no user Tick(). Just whatever the engine defaults to. Of course if you have custom behavior (say for monsters), this would be unavoidable. But context in thread is static decorative objects. The point is, just rolling with the engine and simply sticking in a +NOINTERACTION is a better solution, VS trying to hack around it actually producers a much larger think time. Even if all I literally do is provide an empty Tick override. 1 to 3 ms VS 10 ms!

krokots wrote:How much Tick overrides will actually produce some visible lag? I've only did this with my 1000 vs 1000 pinkies battles, and inside Tick override, every one had Actor Iterator within another Actor Iterator. Just then I got definite lags, but it was still very much playable.


I tested with static decorative objects. The situation changes completely with monsters, who you obviously need custom Tick overrides otherwise ZScript would be pretty much useless.

You can gauge performance of your script code by typing "stat think" in the console.
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Apeirogon » Fri Feb 09, 2018 7:29 am

Nash wrote:Even if all I literally do is provide an empty Tick override

Really? Empty tick
Code: Select allExpand view
override void tick()
{
}

require more processor time than default?
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Blue Shadow » Fri Feb 09, 2018 9:44 am

What? You don't believe him?
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Nash » Fri Feb 09, 2018 10:17 am

Apeirogon wrote:
Nash wrote:Even if all I literally do is provide an empty Tick override

Really? Empty tick
Code: Select allExpand view
override void tick()
{
}

require more processor time than default?


Yes (as messed up as it sounds). "stat think" doesn't lie. Perhaps someone well-versed with the ZScript VM can explain why.
User avatar
Nash
Nash Muhandes
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Apeirogon » Fri Feb 09, 2018 1:05 pm

Blue Shadow wrote:What? You don't believe him?

For me its sounds like "1+1=3". Yes, its true in some multiplicative group of integers modulo n, ACHTUNG!!! STRONG MATHEMATICAL WITCHCRAFT!!!!, but its pnly in very, wery abstract part of math.

Nash wrote:"stat think" doesn't lie

Or it lie, like everyone else...
Whats this? Machine instruction parser? Some binare memory editor from deeps of cheat engine? С/С++ debugger?
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Arctangent » Fri Feb 09, 2018 1:16 pm

Apeirogon wrote:For me its sounds like "1+1=3".

The part of the equation you're missing is the fact that the ZScript VM is slower than ZDoom just running the native code itself. And +NOINTERACTION causes ZDoom to skip most of the native code, anyway. So it's not exactly odd that calling the ZScript VM every tic, even to do nothing, causes worse performance than just letting ZDoom tell most of the code to fuck off using its own methods.
User avatar
Arctangent
squawky
 
Joined: 06 Nov 2014
Discord: SquawkyAtan#2371

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Matt » Fri Feb 09, 2018 7:21 pm

Let's say I needed a decoration that would have to call SetOrigin every single tick and only had a single animation frame (or was invisible so a TNT1 A 1;wait; would suffice).

Would it be more efficient to do this in a spawn state and "wait", or use a tick override?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
 
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby Apeirogon » Sat Feb 10, 2018 4:47 am

Arctangent wrote:So it's not exactly odd that calling the ZScript VM every tic, even to do nothing, causes worse performance than just letting ZDoom tell most of the code to fuck off using its own methods.



Look at this.
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby krokots » Sat Feb 10, 2018 5:41 am

Apeirogon wrote:
Arctangent wrote:So it's not exactly odd that calling the ZScript VM every tic, even to do nothing, causes worse performance than just letting ZDoom tell most of the code to fuck off using its own methods.



Look at this.

That just confirms, if NOINTERACTION is true, the code skips almost 500 lines of code, not counting other functions.
krokots
 
Joined: 19 Jan 2010

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby FishyClockwork » Sat Feb 10, 2018 6:41 am

So, bottom line is I should never ever override Tick() unless it's, like, one or two very special actors in the entire map?
This is rather discouraging.
User avatar
FishyClockwork
 
Joined: 23 Feb 2011

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby phantombeta » Sat Feb 10, 2018 8:33 am

No, not at all!
If that were so, GZDoom would be running extremely slow now. Quite a bit of C++ code has been exported/converted to ZScript, including entire classes. (for example, FastProjectile is completely written in ZScript)
User avatar
phantombeta
In the meadow of sinful thoughts, every flower's a perfect one
 
Joined: 02 May 2013
Location: The United Soviet Socialist Dictatorship of Hueland
Discord: phantombeta#2461
Twitch ID: doom2fan

Re: [BUSTED] Making an ultra light Tick() in ZScript

Postby FishyClockwork » Sat Feb 10, 2018 9:02 am

Yeah, I just realized FastProjectile also overrides Tick().
I should start paying more attention and read the forums more often. >_>

Then again, a FastProjectile isn't something that exists for very long. I guess moral of the story is, be careful which functions you override? Or maybe I should stop worrying over a few milliseconds.
User avatar
FishyClockwork
 
Joined: 23 Feb 2011

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest