Show Posts
|
|
Pages: [1]
|
|
2
|
Game Development / Performance Tuning / Designating threads to specific cores?
|
on: 2011-09-27 03:40:05
|
Hey everyone, My current project is a Minecraft server (as some of you know), and I'm trying to create the best thread pattern possible. I was wondering if there is a way for me to explicitly tell my system to plant a thread on a SPECIFIC core/processor thread. My system has 2 cores (2 threads each) and I know that the software will only every be run on rigs with 4+ available "processors" (as determined by Runtime#availableProcessors()). There are only four threads that I think I'll need to run, so I figured that if I could have each thread run on each core, it would work the best. So, is there a way to do this? Or am I thinking this completely wrong, and I should do it a different way? Thanks 
|
|
|
|
|
7
|
Game Development / Game Mechanics / Re: best way of loading character(player) files?
|
on: 2011-09-22 04:04:00
|
"XML Files can get up to 40Kb"
Uh, they can get up to 40 gigs if you want, or bigger yet. There's no property of XML that makes a certain size intrinsic to them. The average D&D character sheet will be perhaps a couple of kilobytes in any reasonable schema I can think of.
You can be penny wise and pound foolish and squeeze every last byte out of a file format you're reading maybe a half dozen of once on startup, or you can use something that's appropriate to the purpose. There's no single right answer, and a lot of it depends on what you're putting into the files, how fast you need to read and write them, and the constraints of the device you're running it on. I wouldn't store minecraft chunks in XML any more than I would store a character sheet in ASN.1 PER.
Obviously they can be as large as they need be, I thought it'd be obvious that I was talking in context of the OP's situation  I used to use XStream, which allowed you to serialize Java objects into XML files, making the process of game player saving easy. Just that files got huge :/
|
|
|
|
|
8
|
Game Development / Game Mechanics / Re: best way of loading character(player) files?
|
on: 2011-09-22 03:24:30
|
|
XML files are GIGANTIC, especially if your player files are going to have a lot of data in them. They can get up to ~40kb with the amount of bytes written for everything.
I personally use Markus Persson's NBT (Named Binary Tag) system, and if I don't feel like implementing that, I just go through a simple GZIP compression processor with the Java API. NBT takes advantage of the 4kb Windows file header (assuming you're using Windows, it auto-adds a 4kb header to every file) and then the data inside of it is also well-compressed and small.
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / Re: How to decide...short, long, int, byte, etc.
|
on: 2011-09-19 16:47:59
|
I try not to restrict myself unless I have a specific reason to use a smaller type.
When in doubt use int and change it later if you need to.
Also premature optimization is the root of all evil. Often the majority of the slowdown in your code is in a tiny percentage of the codebase and more often than not it is in an area you aren't expecting. Only a profiler will tell you for sure. Readability and simplicity are my most important criteria when writing new code.
Thank you all very much (especially you!), I've learned something now  I can make variables a byte with a value of more than 127 
|
|
|
|
|
12
|
Game Development / Performance Tuning / Re: Ghost thread eating performance! LWJGL...
|
on: 2011-09-18 18:56:12
|
Like I said, I'm not doing anything with threads. Your game isn't doing anything on threads? Or do I misunderstand? Java runs multiple threads in and of itself, and if you aren't organising your program's components into threads, Java will try to run everything on a single thread. That being said, it will probably be really slow, and it will probably eat up CPU.
|
|
|
|
|
14
|
Game Development / Performance Tuning / Re: Review my thread pattern?
|
on: 2011-09-14 00:40:53
|
Now that I think about it, you will always have performance gain from multithreading your file i/o
...
reading from hdd is synchronous so that won't happen, requests to it are queued
It doesn't matter how you 'reason' your way out, it's simply much faster to write large amounts of contiguous bytes, one file at a time. A HDD doesn't work like your average I/O queue, where the throughput is constant. The more time the (mechanical) head is moving (due to seeking), the more throughput you lose. If you write a big file, the head hardly moves. If you write two a big files, the head moves back and forth on each write (lets assume every 4K). Every seek takes about 5-10ms, which limits your seeks to 100-200 per second (IOPS). 100 * 4K = 400K / sec 200 * 4K = 800K / sec This is worst-case scenario, mind you, but the more files you concurrently read/write, the more likely it becomes that you reach that dreadful performance. This is also why copying a directory-structure with lots of tiny files has such horrible performance: every dozen reads are followed by a seek and the writes are also all over the place... I think you're thinking too much into it  If the benchmark says that dedicating more than one thread to file I/O operations executes an operation faster than on a single thread, it's fair to assume that you should probably dedicated more than one 
|
|
|
|
|
15
|
Game Development / Performance Tuning / Re: Review my thread pattern?
|
on: 2011-09-13 03:30:57
|
|
Only things being written to or read from are Minecraft save files (small data region files and one ~2mb level save) and player saves. Player saves can't go above like 8kb, depends on the amount of items they have in their inventory.
|
|
|
|
|
16
|
Game Development / Performance Tuning / Re: Review my thread pattern?
|
on: 2011-09-09 17:04:20
|
how does it make sense to multi thread the player updating but single thread your IO (reading/writing of packets, adding to queue, that part)
unless I misinterpreted
I haven't had time to think about file I/O ops yet...now that I think about it, I don't think it would be that easy to execute a lot of I/O operations on one thread. Looking at how I've mixed my pattern up a bit (I run using Netty networking framework now, so its threads are accounted for) I'm now looking at something like this (not including Netty) : Entity updating ~ Number of threads equals number returned from Runtime#availableProcessors() File I/O ~ Number of threads equals number returned from Runtime#availableProcessors() OR I might do that number / 2, depends on which works better World updating ~ One thread per running world, this works fine because Minecraft servers often have multiple worlds running, and the amount of tasks executed here is small On my beta MC server, I will be running one world for a while until I feel it necessary to test more than one, which means I'll be running 9 non-networking threads on my 2-core hyperthreading processor @ 2.93 GHz. If it can run a CraftBukkit server with 25 people just fine (~20% CPU) it can run mine ALSONot relevant to my current situation, but.. You said it would be bad for networking packet I/O, but I've seen (and talked to the people who've made) gaming servers that run Networking I/O operations on one thread each. As long as that thread is dedicated to a specific operation, and you do all you can to make it do as little as possible while still doing its job, you can easily get it done.
|
|
|
|
|
17
|
Game Development / Performance Tuning / Review my thread pattern?
|
on: 2011-09-05 20:22:20
|
I'm currently building an implementation of the Notchian Minecraft server and I wanted to run my thread pattern past you guys  1 2 3 4 5
| 1. Entity updating thread pool, # of threads is number of processors; this loops through all connected entities and updates them...updates are placed in a queue every tick and emptied at the end, runs at 50ms 2. File I/O single thread, saves all world(s) and players to file, can be queued by the server GUI to execute an unexpected save, runs at 3 minutes 3. Server socket mgmt. single thread, selects all currently selectable channels and sends them to appropriate method: accept, read, or write, runs at 600ms 4. Server packet flow mgmt. single thread, grabs all upstream packet requests in its queue and processes them, followed by sending all downstream packets in the queue to appropriate clients, it does this by polling every Session object's instance for its queue, runs at 50ms 5. World update single thread, contributes to packet flow queue by consuming Task objects that can be converted into downstream packets, updates world time, runs at 50ms |
Unfortunately, most threads must run at 50ms because that is how Minecraft is built to work (time has to be updated every 50ms, and there's no use in dedicating one thread to updating a long for the sake of not having two other threads run at the same tick). I would much prefer something like 10/20ms, because my machine is quite incredible and is comfortable with pretty much anything  I'm asking you guys to tell me what you think of this thread pattern for a game like Minecraft...will it encounter a problem, will it perform slowly, etc. Thanks 
|
|
|
|
|
18
|
Game Development / Game Play & Game Design / Re: Use of Scripting Languages ?
|
on: 2011-09-05 19:43:35
|
|
I personally only find myself utilizing scripts (and usually only for plug-ins built alongside an API of mine) when I'm wanting other people to contribute to parts of the game's development...people that are less experienced with Java.
Scripts are overall just a waste of environment building time if you're going to develop by yourself.
|
|
|
|
|
19
|
Game Development / Networking & Multiplayer / Re: Bugs in nio? I'm paranoid!
|
on: 2011-09-05 19:38:40
|
Hey! I made a thread over at gamedev about a problem I had with networking. One respons I got said that Java nio has bugs that has not been fixed. Is this really true? I find it strange, but he sounded pretty sure. Take a look: http://www.gamedev.net/topic/604811-how-common-is-data-errors-in-tcp/Also, I started thinking about using some sort of networking library instead. I want to make an MMO that can support a few hunderd players, and I want to use TCP. I want something that just works so that I can get on with my game. I have looked a bit at Mina, and it seems nice. Any tips or suggestions? My first post here :p I've worked on RuneScape private servers before, and I'm currently working on a Minecraft server implementation, much like CraftBukkit. What I've found is that, no matter how hard you try, using libraries built on top of NIO isn't what I want. I much prefer the ability to make it as lightweight and controllable as possible: that means, I like to just use my own implementation of the java.nio package. That goes without saying that Netty/MINA/etc. are bad, but I found myself uncomfortable with trying to "master" the usage of them at the cost of possibly using them wrong. I looked up "java nio server example" on Google and found an even better one. I can't link right now but you can try it yourself! I believe it was the fourth result on Google. Being paranoid of bugs is quite OK -- it's understandable. However, I can assure you that I've used to java.nio lib as it is plenty of times and have yet to encounter and sort of error that was caused by the API and not by me messing something up.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|