Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Performance Tuning / Re: Designating threads to specific cores? on: 2011-09-27 02:11:33
All threads are distributed among cores automatically.

That's what I thought. Sucks :/ Hopefully my computer can designate it well enough, lol.
2  Game Development / Performance Tuning / Designating threads to specific cores? on: 2011-09-27 01: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 Cheesy
3  Game Development / Networking & Multiplayer / Re: Apache MINA on: 2011-09-25 22:27:20
Didn't see, it was in the Top 10, so does it really matter?
4  Game Development / Networking & Multiplayer / Re: Apache MINA on: 2011-09-25 19:17:14
I personally use JBoss Netty...find it much more user-friendly.
5  Game Development / Newbie & Debugging Questions / Re: New to the scene, figured I'd introduce myself! on: 2011-09-24 22:35:57
Welcome to JGO, my experience here is great and I hope yours will be too Smiley
6  Game Development / Game Mechanics / Re: best way of loading character(player) files? on: 2011-09-24 15:45:02
My say is either use or save in a compressed stream, i.e. GZip. NBT is nice because of organization, the only problem is that you have to develop a large API just for handling it. I'm thinking about releasing that API, though, so it can be more easily used.
7  Game Development / Game Mechanics / Re: best way of loading character(player) files? on: 2011-09-22 02: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  Stare

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 01: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 14: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 Smiley

I can make variables a byte with a value of more than 127  persecutioncomplex
10  Game Development / Newbie & Debugging Questions / How to decide...short, long, int, byte, etc. on: 2011-09-19 02:40:00
I have always wondered -- when you are thinking about creating an immutable number (a constant), is it smart to use the smallest possible value? For example, if it will only be lower than 255, should I make it a byte? Etc.
11  Game Development / Newbie & Debugging Questions / Re: server wont run? on: 2011-09-19 02:20:57
You shouldn't be throwing any exceptions in the #main() method. Nothing calls it.
12  Game Development / Performance Tuning / Re: Ghost thread eating performance! LWJGL... on: 2011-09-18 16: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.
13  Game Development / Performance Tuning / Re: Review my thread pattern? on: 2011-09-16 02:30:15
Hehe, this is getting kind of ridiculous. He's making a Minecraft server for god's sake. Single threaded IO should be better as it's easier to use.

Oh, was there an OP?  Smiley

Why hello  Tongue

Quite a conversation I started...haha
14  Game Development / Performance Tuning / Re: Review my thread pattern? on: 2011-09-13 22: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 Smiley 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  Wink
15  Game Development / Performance Tuning / Re: Review my thread pattern? on: 2011-09-13 01: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 15: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 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 Wink


Not 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 18:22:20
I'm currently building an implementation of the Notchian Minecraft server and I wanted to run my thread pattern past you guys Tongue

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 Smiley

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  Grin
18  Game Development / Game Play & Game Design / Re: Use of Scripting Languages ? on: 2011-09-05 17: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 17: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:

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.
Pages: [1]
EgonOlsen (60 views)
2018-06-10 19:43:48

EgonOlsen (42 views)
2018-06-10 19:43:44

EgonOlsen (61 views)
2018-06-10 19:43:20

DesertCoockie (241 views)
2018-05-13 18:23:11

nelsongames (142 views)
2018-04-24 18:15:36

nelsongames (141 views)
2018-04-24 18:14:32

ivj94 (883 views)
2018-03-24 14:47:39

ivj94 (144 views)
2018-03-24 14:46:31

ivj94 (795 views)
2018-03-24 14:43:53

Solater (159 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!