Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading scripts too slow. #2082

Closed
xbxymax opened this issue May 21, 2019 · 11 comments
Closed

Loading scripts too slow. #2082

xbxymax opened this issue May 21, 2019 · 11 comments

Comments

@xbxymax
Copy link

xbxymax commented May 21, 2019

I have been using skript2.2 fix v7b for the 1.7.10 server
I have my own set of scripts, all of which add up to about 300kb
But it takes less than 30 seconds to load
We recently started working on the 1.12.2 script and used the latest version of skript
With only a 30kb script in place so far, it takes 10 seconds to load, and it's hard to imagine how long it will take to load later when it's all done
So I want to ask if there is any way to improve the loading speed, or asynchronous loading? I remember a previous version had a syntax for asynchronous loading, but I can't find it now

@Moderocky
Copy link
Member

Generally, the things that slow down loading to that extent are a few bits of addon syntax that have long parsing times.
If memory serves, the Skellett title, skRayFall’s playsound and a few others have a massive effect on this. I don’t remember anything in vanilla skript doing this. How extensively are you using addons?

@xbxymax
Copy link
Author

xbxymax commented May 21, 2019

Generally, the things that slow down loading to that extent are a few bits of addon syntax that have long parsing times.
If memory serves, the Skellett title, skRayFall’s playsound and a few others have a massive effect on this. I don’t remember anything in vanilla skript doing this. How extensively are you using addons?

I have checked what you said before.
I try to avoid all the things that can be avoided, such as the following code will prolong the load time
"&f%convert Unix {_b1::2} to date formatted as "" yyyyy.mm.dd HH: MM :ss""%"
I've deleted everything like that.
Admittedly, the loading was slow

@Moderocky
Copy link
Member

When updating from the old versions, I didn’t notice an increase in load time to the extent that you’re reporting.
I would definitely suggest checking suspicious syntax from addons to see how long the parsing takes. A few can take multiple seconds per use.

@tyhh00
Copy link

tyhh00 commented May 22, 2019

I'm also having similar issues, I've built my codes in dev36 and I recently upgraded to 1.12, I kinda thought i was the only one facing the issue, currently looking at what may be causing it but the lag started to occur after we regexed some code to suit the 1.12 build

We changed:
|| to " and " under with lore conditions
play raw sound "" at ___ with pitch __ volume __ TO play sound "" with volume ____ at ____
lore of player's tool to "%lore of player's tool%" under conditions containing "if" and "contain"

Before changing all those expressions, our skripts loaded in 1 minute 0.52s and it now took 13minutes and 57s which is almost 15x slower... I'm currently tryna investigate on my local server but its taking a long time to load up (currently trying to test out what is causing the slow startups)

@tyhh00
Copy link

tyhh00 commented May 22, 2019

Not sure, but I'm almost certain it isn't an issue with skript but Tuske @xbxymax I'm not sure if you also have tuske guis implemented in your code but when I # these 3 lines

create a gui slot {_slot} of player with light green clay named "&6&m<&8&m--------&8&l(&e&l!&8&l)&8&m--------&6&m>" with lore "&e&l> &7Boost: &eFortune Boost" and "&e&l> &7Upgrade: &e%{_fortune}%%% &8-> &e%{_uppercent}%%% &8(&f+%{_increment}%%%&8)" and "&e&l> &7Chance: &e%{_chance}%%% Success Rate" and "" and "&7Left-Click me to upgrade!" and "&6&m<&8&m--------------------&6&m>" to run player command "/pickaxe levelup FortuneBoost %{_increment}% %arg-1% %arg-2% %arg-3%"

create a gui slot {_slot} of player with light blue clay named "&6&m<&8&m--------&8&l(&e&l!&8&l)&8&m--------&6&m>" with lore "&e&l> &7Boost: &eToken Boost" and "&e&l> &7Upgrade: &e%{_Token}%%% &8-> &e%{_uppercent}%%% &8(&f+%{_increment}%%%&8)" and "&e&l> &7Chance: &e%{_chance}%%% Success Rate" and "" and "&7Left-Click me to upgrade!" and "&6&m<&8&m--------------------&6&m>" to run player command "/pickaxe levelup TokenBoost %{_increment}% %arg-1% %arg-2% %arg-3%"

create a gui slot {_slot} of player with yellow clay named "&6&m<&8&m--------&8&l(&e&l!&8&l)&8&m--------&6&m>" with lore "&e&l> &7Boost: &eEnergy Boost" and "&e&l> &7Upgrade: &e%{_EnergyBoost}%%% &8-> &e%{_uppercent}%%% &8(&f+%{_increment}%%%&8)" and "&e&l> &7Chance: &e%{_chance}%%% Success Rate" and "" and "&7Left-Click me to upgrade!" and "&6&m<&8&m--------------------&6&m>" to run player command "/pickaxe levelup EnergyBoost %{_increment}% %arg-1% %arg-2% %arg-3%"

The delay was reduced significantly. I'm pretty sure this is an issue with Tuske now but eh;/ I'm even using pickachu's 1.8.3 tuske patch, there is still this lag. Or maybe its 1.8.3's patch that causes the lag, not quite sure...

@bensku
Copy link
Member

bensku commented May 23, 2019

Asynchronous loading was experimented with, but unfortunately it was never stable enough. A new Skript parser has been planned for a few years, but it is quite difficult to implement and integrate.

@xbxymax
Copy link
Author

xbxymax commented May 24, 2019

I'm also having similar issues, I've built my codes in dev36 and I recently upgraded to 1.12, I kinda thought i was the only one facing the issue, currently looking at what may be causing it but the lag started to occur after we regexed some code to suit the 1.12 build

We changed:
|| to " and " under with lore conditions
play raw sound "" at ___ with pitch __ volume __ TO play sound "" with volume ____ at ____
lore of player's tool to "%lore of player's tool%" under conditions containing "if" and "contain"

Before changing all those expressions, our skripts loaded in 1 minute 0.52s and it now took 13minutes and 57s which is almost 15x slower... I'm currently tryna investigate on my local server but its taking a long time to load up (currently trying to test out what is causing the slow startups)

Thirteen minutes. That's an exaggeration.
I've used skellett's mysql syntax, asynchronous code, and tuske's GUI syntax.
And the whole has been changed, all from the function to the command format
I think no matter how I change it, it is inevitable that the load time is too slow, so now I will complete the code and only load it when the server is started, and other times I will not touch it

@xbxymax
Copy link
Author

xbxymax commented May 24, 2019

Asynchronous loading was experimented with, but unfortunately it was never stable enough. A new Skript parser has been planned for a few years, but it is quite difficult to implement and integrate.

I wish you good luck

@jaylawl
Copy link
Contributor

jaylawl commented Jun 3, 2019

Make custom functions for code that takes long to parse, then call the functions instead of putting that code everywhere. Here is an example:

function playPlayerSound(s: text, v: number, p: number, pl: players):
    loop {_pl::*}:
        play sound {_s} with volume {_v} and pitch {_p} at loop-value's location for loop-value

function playLocalSound(s: text, v: number, p: number, l: location):
    play sound {_s} with volume {_v} and pitch {_p} at {_l} for all players

I use these functions to play sounds, because this code would otherwise take ridiculously long to parse. This is just a workaround of course, but it will help you.

As it seems, you have a lot optimization to do. I have ~800 kB worth of scripts and it reloads within 6-7 seconds (this includes using addons like TuSKe and skrayfall).

@Matocolotoe
Copy link
Contributor

Matocolotoe commented Jun 5, 2019

I recently did the same for my server @jaylawl, it's indeed really helpful

Looks like the parser takes more time to reload scripts if this is used
if {boolean}:
instead of this
if {boolean} is true:

Can also confirm that Skellett titles and sounds effects increase the "laggy" reload

@Wealthyturtle
Copy link
Member

Closing this issue as it seems to be affected by Skript addons, and #1780 already covers asynchronous script loading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants