Drastically Improve Variable Loading Speed - #8783
Open
erenkarakal wants to merge 8 commits into
Open
Conversation
erenkarakal
requested review from
APickledWalrus and
cheeezburga
and removed request for
a team
July 20, 2026 13:09
Member
|
As for the comparator, I've also looked into optimizing it, and it's pretty close to as good as it can be without changing behavior afaik. Not an easy source of performance at least. |
sovdeeth
requested changes
Jul 29, 2026
sovdeeth
left a comment
Member
There was a problem hiding this comment.
I would also like to see junit tests for the csv parser with a focus on edge cases
| int start = pos; | ||
| while (pos < n && line.charAt(pos) != ',') { | ||
| if (line.charAt(pos) == '"') | ||
| return null; // quote in the middle of an unquoted value |
Member
There was a problem hiding this comment.
this might be allowed (quotes in things like var names?) Please double-check.
|
|
||
| import java.io.EOFException; | ||
|
|
||
| public class FastEOFException extends EOFException { |
Member
There was a problem hiding this comment.
javadocs for why this exists would be good
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Disclaimer
To anyone looking to test this build. Make a backup of your variables file!
Problem
Skript's variable loading can be very slow as you get more variables. There are 3 main bottlenecks during variable loading.
Regex is used to read the variables.csv file lines. It makes the code readable, but around 17% of the time is spent matching the line to the regex pattern.
Inside
DefaultYggdrasilInputStream,throw new EOFException()is used as a breakpoint. When this is called millions of times, it ends up taking up more than 20% of the tick.The variable name comparator in
VariablesMapis taking 15% of the tick. I looked into it, but it's not addressed in this PR. I am not sure if it can be optimized.Solution
1) Added a new
FastEOFExceptionexception. This exception overridesfillInStackTrace()to have an empty implementation, which makes variable loading around 30% faster. (33.8s -> 24.2s when loading 15 mil variables)2) Rewrote the
splitCSVmethod to not use regex, which is an additional 25%~ boost (24.2s -> 19.0s when loading 15 mil variables)The rest of the changes are code cleanup, just IJ suggestions.
Testing Completed
The speed tests were done with a single list of 15 million global variables, each variable having a different number. This PR still needs heavy testing with different variable types and varying variable names to make sure no breaking changes were added.
This python script was used to generate the variables:
Completes: none
Related: none
AI assistance: Claude Sonnet 5 Medium was used in
splitCSVrewrite