Cuberite Forum
MCServer Development Discussion - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: MCServer Development Discussion (/thread-186.html)

Pages: 1 2 3 4 5 6 7 8 9


RE: MCServer is open source! - rs2k - 10-24-2011

(10-24-2011, 07:02 AM)necavi Wrote: Well, at least previously there was a 200 mob limit in minecraft, I'm not sure if it was a vanilla limit (I believe it was) but having it be that low created problems on larger servers, especially if Mob Towers were allowed, no one else would get a single mob! My question would be whether this limit is entirely based on the server itself, or the hardware running it, I would think that there would be some variance in the amount of mobs it could support with higher/lower end hardware.


I think it has to do with the code. If I'm online about 20 minutes or so (rough guess), the mobs keep spawning until my connection times out. Right after I time out I get MCServer has crashed in the console.

MCServer resources stay very low when it happens. CPU is constantly around 1%- 3% of one core and RAM usage is around 0.1% - 0.2% of 16GB on my Ubuntu machine.

It happens on my windows machine as well, and both RAM and CPU also stay low.


RE: MCServer is open source! - necavi - 10-24-2011

Any chance you can test how much of your connection is being used? Is your server hosted at a datacenter or at home? (I'm especially curious because this one of the things I had hoped it was possible to change). Also, I haven't looked into it enough to see, are all NPC locations sent to all clients?


RE: MCServer is open source! - rs2k - 10-24-2011

I set mobs to spawn at 1 per second with the first mob spawning at
14:07:06

The console put out spawn mob info every second until it finally disconnected me

14:08:30
CPU usage 1-2% of one core
RAM usage 0.1% of 16GB
Net usage to me: 0.132 Mb/s

14:16:24
CPU usage 4-6% of one core
RAM usage 0.2% of 16GB
Net usage to me: 0.6 Mb/s

14:19:55
CPU usage 8-10% of one core
RAM usage 0.2% of 16GB

14:22:20
CPU usage 9-11% of one core
RAM usage 0.2% of 16GB
Net usage to me: 1.29 Mb/s

14:24:20
CPU usage 9-11% of one core
RAM usage 0.2% of 16GB
Net usage to me: 1.54 Mb/s
Mobs finally climbed up high enough to kill me instantly.
Can't spawn without getting killed nearly instantly
WARNING: cTracer: Start

14:25:36
CPU usage 10-12% of one core
RAM usage 0.2%
Net usage to me: Didn't catch this number in time.
MCServer has crashed!

18 mins 18 seconds of producing mobs every second should means about 1,098 mobs.

http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.14.17.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.14.17.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.14.23.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.14.26.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.14.50.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.15.14.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.21.00.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.21.01.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.21.03.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.21.05.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.21.07.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.21.08.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.22.29.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.22.51.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.24.50.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.24.53.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.24.57.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.24.59.png
http://dl.dropbox.com/u/14526521/mobcrash/2011-10-23_16.26.30.png


RE: MCServer is open source! - FakeTruth - 10-24-2011

Lol.. that's just sillyTongue

MCServer IS capable of holder even more mobs than that, but the bandwidth is simply WAYYY too high!

If you have multiple players on your server, you'll disconnect even faster. And if a player with low internet speed tries to join the server, he'll disconnect as well, because the server can't send packets to him fast enough. I can't think of an easy way to fix this, but I suppose it has something to do with keeping track of what and how many packets are being sent to each client seperately.

Right now a mob might be sending its location to the clients 60 times per minute (probably more, but whatever), if the server is only capable of sending out 30 packets per minute, the queue will build up, with location packets of the same entities. I suspect these need to be filtered, so there's only one packet for each entity in the queue.


RE: MCServer is open source! - rs2k - 10-24-2011

That makes sense. I can't get anywhere near that many mobs on bukkit. I don't really see any reason to have that kind of network traffic. A limit of how many mobs can be around any players seems like a good idea. 1000 mobs all around me is just ridiculous.

When someone with a lower connection speed gets disconnected, will the server crash as well? Or does it happen only when the last person gets disconnected in that manor?

Where are the packets queued at? Is the operating system doing the queuing or is MCServer doing it?


RE: MCServer is open source! - FakeTruth - 10-24-2011

MCServer should NEVER crash, but unfortunately it does sometimes Sad and I don't know why

The packet queues are stored in cClientHandle.cpp (line 90 and 91). Queued packets are sent from cClientHandle::SendThread() which is, as the name says, threaded, so sending data does not impact performance. Normally sending data stops the program until the data has been sent (I think).


RE: MCServer is open source! - rs2k - 10-24-2011

(10-24-2011, 08:29 AM)FakeTruth Wrote: MCServer should NEVER crash, but unfortunately it does sometimes Sad and I don't know why

The packet queues are stored in cClientHandle.cpp (line 90 and 91). Queued packets are sent from cClientHandle::SendThread() which is, as the name says, threaded, so sending data does not impact performance. Normally sending data stops the program until the data has been sent (I think).

I look at the queues and how they're stored. I'd imagine filtering them would be too difficult and could cut down on traffic quite a bit with a long queue.


RE: MCServer is open source! - FakeTruth - 10-24-2011

A little bit of filtering is already done in cClientHandle::Send() line 879 by looking for RelativeEntityMoveLook packet with the same UniqueID's, it cut down a lot of traffic after I put that inTongue

Aaaand I think I just found a memory leak there. The duplicate packet is removed from the queue, but not deleted.


RE: MCServer is open source! - rs2k - 10-24-2011

Obviously, I know the server isn't ready, but I decided to try open the test server to the public to see what would happen.
Here are some observations I made:

There are hacks that apparently cause the packet queue to grow large. I see several messages about packets in queue until the server finally crashes.

I also saw strings on the console that flew by like this:
[15:52:23] Health: 3
[15:52:23] Health: 4
[15:52:23] Health: 5
[15:52:23] Health: 6
[15:52:23] Health: 7
[15:52:23] Health: 8
[15:52:23] Health: 9
[15:52:23] Health: 10
[15:52:23] Health: 11
[15:52:23] Health: 12
[15:52:23] Health: 13
[15:52:23] Health: 14
[15:52:23] Health: 15
[15:52:23] Health: 16
[15:52:23] Health: 17
[15:52:23] Health: 18
[15:52:23] Health: 19
[15:52:23] Health: 20
[15:52:23] Health: 21
[15:52:23] Health: 22
[15:52:23] Health: 23
[15:52:23] Health: 24
[15:52:23] Health: 25
[15:52:23] Health: 26
[15:52:23] Health: 27
THOUSANDS of these messages is what caused one of the crashes. The number eventually went negative. It looks like a stack overflow.
That lagged the server and eventually caused it to crash like this:

[15:44:24] Got ping
[15:44:24] Deleting client
[15:44:24] -76 0 -2 Destroying on action765
[15:44:24] -76 0 -2 Destroying on action765
[15:44:24] -75 0 -2 Destroying on action765
[15:44:24] -73 0 -2 Destroying on action765
[15:44:24] Destroy that entity! 768
[15:44:24] Destroy that entity! 794
[15:44:24] Destroy that entity! 795
[15:44:24] Destroy that entity! 796
[15:44:24] Destroy that entity! 797
[15:44:24] To tick: 7
[15:44:24] To tick: 86
[15:44:24] 1. Stack size: 0
[15:44:24] 2. Stack size: 1
[15:44:24] 3. Stack size: 2
[15:44:24] Calling bound function!Big Grin
[15:44:24] ok. Stack size: 0
[15:44:24] From -76 -2 To -77 -2
[15:44:24] From -77 -2 To -76 -2
[15:44:24] Health: -1214
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted



I also noticed when someone DC'd there would be several spawn messages for someone who was still on the server. I'm not sure what those messages mean. Does it mean mobs around the person who DC'd get teleported to someone else?

I aslo noticed running mc server like this:
./MCServer > log.log
and using
tail -f log.log
seemed to improve performance when someone was causing an action that spammed the console. Maybe moving the console output to anther thread could improve performance?



Making the server immune to most attacks is also a high priority for me. It's incredible how many people try to attack servers. I get attacks several times a day on my bukkit server.


I'd like to put in something that disconnects or bans a player that is trying to do too much at once. Like trying to use a nuke client for example. I know that might sound like something a plugin should do, but I think of that more as basic security.


RE: MCServer is open source! - FakeTruth - 10-24-2011

True, I just never added that security.

Eventually MCServer should not spam the console, it's just for debugging so IMO there's no need for optimization there.

I don't know what these health messages mean, but that the health turns out negative sounds like something serious.