On Mon, 26 Dec 2016 20:44:40 +0100
"Enrico Weigelt, metux IT consult" <***@gr13.net> wrote:
> On 25.12.2016 22:58, Michael T. Pope wrote:
> > There is usually only zero, one, or two game objects (client + server).
>
> Are client and server both running in the same process ?
Yes in single player, no in multiplayer. For game play purposes there is
no need for them to be in the same process in single player either. OTOH
for development purposes, debug mode is pretty much useless without access
to the server in the client, and FreeCol is *not* at a stage where we can
do without debug mode yet.
> In which ways do these two instances differ ?
None AFAICT.
> Another open question: what about the Specification class ? Can there
> be multiple instances at the same time ?
Specification is a field in Game. It should follow the same pattern as
Game. Sometimes the Specification field in the client or server Game is
null, sometimes it is changed, and then messaging occurs to synchronize it
with the other party and the other clients. IIRC this can only happen
independently of Game at the pre-game stage (see Game + MapGenerator
Options). Once the Game starts, Specification should not change.
> Ah, AI players are basicly just usual players ?
Not yet. AIs still essentially live in the server, and exploit the extra
information available to them mercilessly. This has been one of my long
term projects --- slowly decouple the AIs to the point that they *could*
be ordinary players. The major obstacle that remains though is that the
AI is just not smart enough, and still relies on blatant cheating.
> Could they, in theory,
> run in a different process, or on a different machine ?
Not yet, but I have been pushing them in that direction, step by step.
The comms portion of this should all "just work". The next *big* step is
to stop the AIs from directly accessing the server Map.
> > As usual I have to ask what problem you are trying to solve? It sounds
> > like you are worried that the getGame calls are inefficient.
>
> Well, they probably do some overhead, as they seem to be called quite
> often, but I don't know much actually take.
>
> I'll yet have to find out, whether
> a) these functions get inlined
> b) they get jit-compiled at all (according to official docs, a method
> has to be called 1k times before jit gets active)
> c) references to long-lived objects or final refs also get inlined
I think you will find the answer is both Yes and No to all of the above:-).
It is complex and depends on a whole range of compiler, run-time and
system parameters. Consider also, if you find out what *your* machine
does, should we make optimization decisions based on just that one
configuration? Remember that FreeCol is intended to run on three
reasonably distinct operating systems, on <whatever> hardware (within
reason), and is sometimes compiled on site by our users so we can not just
ship .jar files and think we know exactly how they will behave.
> I'm not so confident w/ java profiling,
Neither am I, but I have used various GUI tools and JRE hacks from time to
time when we had a serious bug that was causing a hang or a massive slow
down. I do not recall much detail, but it was not difficult to work out.
Here is a chance for you to learn:-).
> > we need to put our effort into stuff that is *broken*.
>
> Okay, which ones do you suggest ?
I can not improve on wintertime's suggestions.
- If you want to work on optimization the display code has *always* been
the major bottleneck every time I checked (modulo the outright bugs and
hangs). The next big category is almost always due to the client-server
I/O with the hottest routines being low in the Java libraries where the
bytes are being shovelled or where we are waiting for input --- there is
not much we can do about that (not our code), but what we could do is
try to read/write less data. There has not been much effort in that
direction, because we struggle just to get to correctness.
- Yes, GUI.createMiniMapThumbNail is a mess. I think it should be
completely rewritten in the MapEditorController (only place it is
called) as just a simple image creation routine. There is no reason for
it to mess with MiniMaps. This problem is blocking a newly contributed
map from being added, so it is important work.
Cheers,
Mike Pope