Conner_
Senior Newbie 
~ Java Game Dev ~
|
 |
«
Posted
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 
|
Find me on GitHub: connergdavisMy current project is called Obsidian Framework and is a private Minecraft server application used to play Multiplayer.
|
|
|
theagentd
|
 |
«
Reply #1 - Posted
2011-09-27 02:04:42 » |
|
All threads are distributed among cores automatically.
|
Myomyomyo.
|
|
|
Conner_
Senior Newbie 
~ Java Game Dev ~
|
 |
«
Reply #2 - Posted
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.
|
Find me on GitHub: connergdavisMy current project is called Obsidian Framework and is a private Minecraft server application used to play Multiplayer.
|
|
|
Games published by our own members! Check 'em out!
|
|
theagentd
|
 |
«
Reply #3 - Posted
2011-09-27 02:44:22 » |
|
Why wouldn't it be able to? Designating them yourself would be a bad idea, as the OS (and Java) can compensate for other programs. If you have another program running a single thread that suddenly starts hogging processing power, if both that program and your program had decided exactly what core to run on, one thread of your program would be severely slowed down. It's better to let the OS handle it and get even performance, as a task split up between multiple threads is only complete when all threads finish, right?
|
Myomyomyo.
|
|
|
princec
|
 |
«
Reply #4 - Posted
2011-09-27 11:04:56 » |
|
It's not as sucky as it sounds - by and large the OS will absolutely try its level best to keep any particular thread on the core in which it started life. If it can't, for any reason, then it's because it reckons it can do a better job by moving it. So relax and enjoy coding and sleep soundly at night  Cas 
|
|
|
|
Riven
|
 |
«
Reply #5 - Posted
2011-09-27 11:11:12 » |
|
It's not as sucky as it sounds - by and large the OS will absolutely try its level best to keep any particular thread on the core in which it started life.
This is not my experience at all (on Windows). It will move all threads around, at an even pace. When running a single-threaded algorithm, all my 4 CPU cores are at 25% usage, not one at 100%.
|
Hi, appreciate more people! Σ ♥ = ¾ Learn how to award medals... and work your way up the social rankings!
|
|
|
princec
|
 |
«
Reply #6 - Posted
2011-09-27 11:17:47 » |
|
Hm that is strange - mostly I get one core jammed at 100% in that situation. Cas 
|
|
|
|
Riven
|
 |
«
Reply #7 - Posted
2011-09-27 11:25:41 » |
|
Relevant specs: Vista 64bit, Intel Q6600 stepping G.
Maybe it's a setting, somewhere, too.
|
Hi, appreciate more people! Σ ♥ = ¾ Learn how to award medals... and work your way up the social rankings!
|
|
|
princec
|
 |
«
Reply #8 - Posted
2011-09-27 11:37:16 » |
|
Vista64, i7 here. But I've had the same experience on every system I've used I think but haven't really got any proof other than my extraordinarily unreliable memory. There are tweaks in the registry to alter this stuff but I've not meddled with them. Cas 
|
|
|
|
Cero
|
 |
«
Reply #9 - Posted
2011-09-27 12:25:10 » |
|
Everyone complains about the PS3 architecture. Admittedly much more complex with 7 async. cores or whatever, but I guess developers are very happy if they don't have to do that kind of stuff.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
princec
|
 |
«
Reply #10 - Posted
2011-09-27 12:51:43 » |
|
I dunno, we're already doing async core programming now using VBOs etc. in OpenGL. It all makes sense really. It'd be nice if you could specify the cores to form into pipelines and stuff a la Transputers. That'd be awesome! Imagine a grid of 8x8 cores or something and you could design algorithms that piped data through in various routes. Cas 
|
|
|
|
theagentd
|
 |
«
Reply #11 - Posted
2011-09-27 14:17:54 » |
|
WAIT...! Is it possible to do VBO uploads from different threads?!
|
Myomyomyo.
|
|
|
princec
|
 |
«
Reply #12 - Posted
2011-09-27 14:33:24 » |
|
I think so, using shared context stuff. But you wouldn't want to, probably. Cas 
|
|
|
|
Roquen
|
 |
«
Reply #13 - Posted
2011-09-27 15:20:27 » |
|
Transputers: I actually did some programming on some T212 at uni...it was a heck of a lot of fun. (I'm totally not a geek or anything)
|
|
|
|
sproingie
|
 |
«
Reply #14 - Posted
2011-09-27 15:49:15 » |
|
Laptop CPUs will typically bounce threads around between cores evenly as a heat management strategy. They should still respect processor affinity settings if you set them explicitly.
|
|
|
|
Riven
|
 |
«
Reply #15 - Posted
2011-09-27 19:36:47 » |
|
Ah, about 5 years ago I set PowerManagement to 'minimal'.
The relevant part seems to be that CPU min=25% and max=100%.
That probably toggles the massive amount of bouncing (or shall we say cache trashing).
|
Hi, appreciate more people! Σ ♥ = ¾ Learn how to award medals... and work your way up the social rankings!
|
|
|
princec
|
 |
«
Reply #16 - Posted
2011-09-27 20:15:58 » |
|
Context switch between threads trash caches anyway even on single core, so probably nothing to worry about. But on a dual core there's definitely massive gains to be had when one busy thread hogs a core and all the other less busy threads just get the other core(s). Cas 
|
|
|
|
|