[Pawn] Long callback execution detected (hang or performance issue) - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Long callback execution detected (hang or performance issue) (/showthread.php?tid=1736) |
Long callback execution detected (hang or performance issue) - GospodinX - 2021-03-07 Hi guys My crash detect log is full with this error Code: Long callback execution detected (hang or performance issue) (every one minute) This is a timer that starts every 60 seconds with a loop Code: for(new i; i < 2000; i) I just need to have this loop. How I can improve it to avoid the error. PHP Code: #define MAX_WOOD 2000 RE: Long callback execution detected (hang or performance issue) - Kwarde - 2021-03-07 https://github.com/Zeex/samp-plugin-crashdetect#configuration Quote:How long a top-level callback call should last before crashdetect prints a warning. This can be set very high (for example 1000000) to only detect functions that have totally hung, or very low (500) to detect functions that complete, but are just slow (thus affecting overall server execution and sync). Default value is 5000 (5 milliseconds). Steps to take: 1- Find out how long exactly it takes to execute the code (You could use YSI's profiling: https://github.com/pawn-lang/YSI-Includes/tree/5.x/YSI_Core/y_profiling) 2- Check if commenting out "SaveWood(i);" still creates those errors (if it's writing to files, it could take some time if 2000 woods are being saved) 3- You could use y_iterate instead for looping. Rather than performing 2000 loops every minute you'd just loop through the existing woods Apart from that, I don't understand the variable names so hard to tell exactly what's what and how it could be improved. Not to mention that not using tabs/spaces (atleast on this forum) makes it harder to read. Spaghetti code if you will. An alternative would be to change the long_call_time parameter in your server configuration file. However that is pretty much just ignoring the problem -- especially if it hangs pretty long (causing desync and laggs). Otherwise you could slightly increase that value. RE: Long callback execution detected (hang or performance issue) - Y_Less - 2021-03-07 Or you could make the timer more frequent, which seems counter-intuitive, but means you can do less each one. So instead of doing 2000 items every 60 seconds, to 200 items every 6 seconds (or 20 every 0.6 seconds). That way, even if the code is still slow it's more spread out. |