-
-
Notifications
You must be signed in to change notification settings - Fork 400
Add timings back with a native event #7994
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
base: dev/feature
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like a decent start for a profiling api
i'm not sure a single timer should be called a profiler, though. Usually a profiler will track multiple execution times and collate them for easy usage rather than just a single execution time. It may be preferable for a user to be able to start a profiler, any executions while it's active are added to that profiler, then be able to stop it and query it for information. Basically what spark does, or what your script does, but built in.
I'm mainly worried that event will be called a tremendous number of times and cause significant slowdown.
public class ProfilerAPI { | ||
|
||
private static volatile boolean enabled = true; | ||
public static final ThreadLocal<Boolean> isFiringProfilerEvent = ThreadLocal.withInitial(() -> false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not so sure about this design for checking if a trigger is in a profiler event. If the thread changes at all (see skript-reflect or skbee async sections), won't it be unreliable?
You should also be targeting dev/feature and use dev/feature, rather than master. Just an fyi. Maybe someone from skriptlang can fix this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if 2 triggers from different threads run at the same time?
needs rebasing |
Gotcha. @JIBSIL just so you're aware ^^ ❤️ |
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com> Co-authored-by: Eren <67760502+erenkarakal@users.noreply.github.com>
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Sovde mentioned with the potential of this being called multiple times, we should probably not be doing profilers for ProfileCompletedEvent
. In my opinion at least.
Co-authored-by: sovdee <10354869+sovdeeth@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to resolve conflicts (also remember to click re-request when you've completed someone's requested changes)
Problem
I was really unhappy with Skript a few weeks ago, when badly coded scripts were lagging my server to 15-17 TPS on 25 players. It was really frustrating not to have Timings, after it was deprecated. Spark is entirely useless for Skript and I needed a better way to profile events.
Solution
I added a native profile API with Profile events which run automatically when code is triggered. It's as lightweight or even more lightweight than timings. I added a new event
on profile available
so that users can see how long their events took. Also, I improved trigger debug verbosity by adding more information like expression and full Skript path in the trigger debugs, so that setting verbosity to debug in the Skript options displays more useful output.Here is the minimum usable code to test my changes:
This is the script that I use on my server that allows to view these in a fully featured way
https://gist.github.com/JIBSIL/c117f881a88e9c28568b89b2f4bb7f7a
Testing Completed
All tests were passed with the gradlew skriptTest command.
Supporting Information
I couldn't get it to be
event-duration
or something more descriptive inon profile complete
, I would appreciate help with that if it's going to be merged. Also, maybe the ProfilerAPI or the Profile events should be public, I don't know Skript's policy on exposing those kinds of APIs so I left them private for now.