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

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
User avatar
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

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
gwHero
Posts: 360
Joined: Mon May 08, 2017 3:23 am
Graphics Processor: Intel with Vulkan/Metal Support
Location: The Netherlands

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

Post by gwHero »

What do you mean by a 'regular' Tick()? Having no override and no extra code?
User avatar
krokots
Posts: 266
Joined: Tue Jan 19, 2010 5:07 pm

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

Post by krokots »

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.
User avatar
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

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
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

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

Post by Apeirogon »

Nash wrote:Even if all I literally do is provide an empty Tick override
Really? Empty tick

Code: Select all

override void tick()
{
}
require more processor time than default?
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

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

Post by Blue Shadow »

What? You don't believe him?
User avatar
Nash
 
 
Posts: 17433
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

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

Post by Nash »

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

Code: Select all

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
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

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

Post by Apeirogon »

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?
User avatar
Arctangent
Posts: 1235
Joined: Thu Nov 06, 2014 1:53 pm
Contact:

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

Post by Arctangent »

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
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

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

Post by Matt »

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
Apeirogon
Posts: 1605
Joined: Mon Jun 12, 2017 12:57 am

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

Post by Apeirogon »

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.
User avatar
krokots
Posts: 266
Joined: Tue Jan 19, 2010 5:07 pm

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

Post by krokots »

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.
User avatar
Fishytza
Posts: 781
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: No Preference
Contact:

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

Post by Fishytza »

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
phantombeta
Posts: 2084
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

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

Post by phantombeta »

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
Fishytza
Posts: 781
Joined: Wed Feb 23, 2011 11:04 am
Preferred Pronouns: No Preference
Contact:

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

Post by Fishytza »

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.
Post Reply

Return to “Scripting”