The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sever goes unstable and crashes
Author Message
Ankron
Apprentice
*

Posts: 20
Likes Given: 3
Likes Received: 2 in 2 posts
Joined: Jan 2015
Reputation: 0



Post: #1
Sever goes unstable and crashes
I'm not sure why the server goes unstable and crashes, I can't see anything in the script that would cause the crash... Do you guys see anything?

AreaSpawner V0.1A
(This post was last modified: 01-25-2015 06:39 PM by Ankron.)
01-25-2015 06:14 PM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #2
RE: Sever goes unstable and crashes
Added [spoiler] and [code] to your post, anyway it seems cutted... use http://www.pastebin.com for big pastes, the thread will load faster and we can read it better than here.
01-25-2015 06:20 PM
Find all posts by this user Like Post Quote this message in a reply
Ankron
Apprentice
*

Posts: 20
Likes Given: 3
Likes Received: 2 in 2 posts
Joined: Jan 2015
Reputation: 0



Post: #3
RE: Sever goes unstable and crashes
Ok, I put it in pastebin and updated the original post.
01-25-2015 06:40 PM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #4
RE: Sever goes unstable and crashes
The passable function is really INSANE, it have up to 8k lines depending on the arg given!! hence up to 4k checks.

As I can see you are checking the Terrains to see if you can walk upon them or not, right? what about selecting terrain types using serv.map(x,y,z).type instead of .terrain and discarding the ones you don't want? something like ...

Code:
local.terrain=<serv.map(<eval <local.x>>,<eval <local.y>>,<argv4>).type>
local.passable=<qval (<local.terrain>==t_water || <local.terrain>==t_rock || <local.terrain>==t_lava) ?0:1>
You can add more checks there, even create new terrain types just to create a 'direct' check instead of 4k of them.

I would even better suggest you to create one definition per valid terrain, something like:

Code:
[defname valid_Terrains]
terrain_valid_1=1
terrain_valid_2=1
...
terrain_valid_22=1
...
terrain_valid_16383=1

and checking it via

Code:
local.passable=<def0.terrain_valid_<serv.map(<eval <local.x>>,<eval <local.y>>,<argv4>).terrain>>

rather than using that big one function (but I prefer the first option).
01-25-2015 07:32 PM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #5
RE: Sever goes unstable and crashes
probably your function is making the server unstable because you're executing too much SQL commands
everytime you execute a SQL command, sphere will freeze until the SQL server return back the SQL response to sphere. On lightweight SQL functions, you won't notice any freeze because it will execute the function in just 0.1s. But if you execute 100x this same SQL command on loop, the total execution time will be increase to 10s (100 x 0.1s) and this will freeze sphere for about 10 seconds until all SQL commands got executed

so unfortunately to fix this you must rewrite your code to make it use less SQL commands

also you can optimize a lot this passable function, reducing 48478647864763874 lines to just a few lines
instead check for every single value, you can check an entire value range on just a single line

this:
Code:
[function passable]
if <argv0>==3
        return 1
elseif <argv0>==4
        return 1
elseif <argv0>==5
        return 1
elseif <argv0>==6
        return 1
elseif <argv0>==7
        return 1
elseif <argv0>==8
        return 1
elseif <argv0>==9
        return 1
elseif <argv0>==10
        return 1
elseif <argv0>==11
        return 1
elseif <argv0>==12
        return 1
elseif <argv0>==13
        return 1
elseif <argv0>==14
        return 1
elseif <argv0>==15
        return 1
elseif <argv0>==16
        return 1
elseif <argv0>==17
        return 1
elseif <argv0>==18
        return 1
elseif <argv0>==19
        return 1
elseif <argv0>==20
        return 1
elseif <argv0>==21
        return 1
elseif <argv0>==22
        return 1
elseif <argv0>==23
        return 1
elseif <argv0>==24
        return 1
elseif <argv0>==25
        return 1
elseif <argv0>==51
        return 1
elseif <argv0>==52
        return 1
elseif <argv0>==53
        return 1
elseif <argv0>==54
        return 1
elseif <argv0>==55
        return 1
elseif <argv0>==56
        return 1
elseif <argv0>==57
        return 1
elseif <argv0>==58
        return 1
elseif <argv0>==59
        return 1
elseif <argv0>==60
        return 1
elseif <argv0>==61
        return 1
elseif <argv0>==62
        return 1
...

can be reduced to:
Code:
[function passable]
if (<argv0> >= 3) && (<argv0> <= 25)
        return 1
elseif (<argv0> >= 51) && (<argv0> <= 62)
        return 1
...
(This post was last modified: 01-26-2015 05:55 AM by Coruja.)
01-26-2015 03:09 AM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,141
Likes Given: 217
Likes Received: 90 in 77 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #6
RE: Sever goes unstable and crashes
HOOOOOOOOLY SHIT!
This is the biggest function I saw in my life.
But really, kinda funny. I hope you didn't write this yourself. lol

And yes, use first code that XuN wrote.

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
01-26-2015 05:37 AM
Find all posts by this user Like Post Quote this message in a reply
Ankron
Apprentice
*

Posts: 20
Likes Given: 3
Likes Received: 2 in 2 posts
Joined: Jan 2015
Reputation: 0



Post: #7
RE: Sever goes unstable and crashes
Na, every script has a process of debugging and making more efficient. It works, problem is it shuts down. Maybe I need to find a way to load/unload all the spawn data when the player enters/exits the region.
01-26-2015 07:57 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #8
RE: Sever goes unstable and crashes
It shuts down because, as Coruja said, Sphere waits for SQL execution so it hangs in the proccess. I gave you alternatives to this function without knowledge of what you want so if they are not good enough you may expose here what do you want so we can help you out.
01-27-2015 01:10 AM
Find all posts by this user Like Post Quote this message in a reply
Ankron
Apprentice
*

Posts: 20
Likes Given: 3
Likes Received: 2 in 2 posts
Joined: Jan 2015
Reputation: 0



Post: #9
RE: Sever goes unstable and crashes
Yep, I've since divided each sql statement into it's own tick, it's stabilized the server. Big Grin Thanks guys.[/align]
01-27-2015 05:32 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 6 Guest(s)