Java AI Interface for Spring
Moderators: hoijui, Moderators
Re: Java AI Interface for Spring
hmm k :/
well. still god luck with that.
The IBM thing...
my SUN JVM is unable to load the native part of IBMs profiling library...
guess it would ned IBMS JVM... well!!!!
edit: just checke, and it IS for IBMs JVM only. DOH!
well. still god luck with that.
The IBM thing...
my SUN JVM is unable to load the native part of IBMs profiling library...
guess it would ned IBMS JVM... well!!!!
edit: just checke, and it IS for IBMs JVM only. DOH!
Re: Java AI Interface for Spring
Ok.. tried Netbeans Profiling.
Worked well and was easy.. until it started profiling. This worked fine too, but it just never spit out any data; no error or warning or something (it tracked the application fine, eg showed used memory and stuff, but no profiling data (eg. caled methods)).
Worked well and was easy.. until it started profiling. This worked fine too, but it just never spit out any data; no error or warning or something (it tracked the application fine, eg showed used memory and stuff, but no profiling data (eg. caled methods)).
Re: Java AI Interface for Spring
Oh, about my __stdcall thing :)
https://jna.dev.java.net/servlets/ReadM ... msgNo=3210
Usefull to know :)
https://jna.dev.java.net/servlets/ReadM ... msgNo=3210
Usefull to know :)
Re: Java AI Interface for Spring
ahhh...
i dont get it. So.. it should with buildbot build of javaaispeed, it should fail, cause i dont use that... why would it only fail if you use hte profiling library? um.. i feel i fogot something.. too little sleep.
i dont get it. So.. it should with buildbot build of javaaispeed, it should fail, cause i dont use that... why would it only fail if you use hte profiling library? um.. i feel i fogot something.. too little sleep.
Re: Java AI Interface for Spring
Never mind me, it has no bearing on your build :)
You link against AIInterface.dll or so, which seems to not use __stdcall in the dll, so all is fine there :)
It's just an issue I had with my messy tests :)
Also, it has nothing to do with profiling :D
I don't know why my profiler fails, but it's not fixable I think, so don't worry about it
You link against AIInterface.dll or so, which seems to not use __stdcall in the dll, so all is fine there :)
It's just an issue I had with my messy tests :)
Also, it has nothing to do with profiling :D
I don't know why my profiler fails, but it's not fixable I think, so don't worry about it

Re: Java AI Interface for Spring
i do use stdcall on 32bit windows builds, through the EXPORT macro in rts/System/exportdefines.h. Thats why i wonder why it does not fail, but.. i'll just believe you for now, as you tell me i dont have to care about it 

Re: Java AI Interface for Spring
Hehe! ^_^
Well, using __stdcall would result in methodname@## kind of names in the dll, that's why it needs special treatment.
In javaaispeed_spring_0.80.4-132-gee9996e.exe there's the file AIInterface.dll, And it has neat tidy method names like: "Clb_0MULTI1SIZE3FriendlyUnits0Unit".
So it looks like you don't use __stdcall, I think :)
My methods on the other hand look like this: "_skirmishAiCallback_Unit_getPos@8", notice the '@8' :)
I think that's the result of __stdcall :)
I knew nothing about this stuff before yesterday though, so I'm not a good person to talk about this
P.s. you can look at your dll with this :D
http://www.ucware.com/apev/index.htm#jaws
Well, using __stdcall would result in methodname@## kind of names in the dll, that's why it needs special treatment.
In javaaispeed_spring_0.80.4-132-gee9996e.exe there's the file AIInterface.dll, And it has neat tidy method names like: "Clb_0MULTI1SIZE3FriendlyUnits0Unit".
So it looks like you don't use __stdcall, I think :)
My methods on the other hand look like this: "_skirmishAiCallback_Unit_getPos@8", notice the '@8' :)
I think that's the result of __stdcall :)
I knew nothing about this stuff before yesterday though, so I'm not a good person to talk about this

P.s. you can look at your dll with this :D
http://www.ucware.com/apev/index.htm#jaws
Re: Java AI Interface for Spring
The funny names are due to name mangling, which is necessary in C++ regardless of the calling convention used. But the interface is in plain C, where mangling isn't required.Well, using __stdcall would result in methodname@## kind of names in the dll, that's why it needs special treatment.
Re: Java AI Interface for Spring
If that's that's the case, then yes, that makes perfect sense to me :DKloot wrote:The funny names are due to name mangling, which is necessary in C++ regardless of the calling convention used. But the interface is in plain C, where mangling isn't required.Well, using __stdcall would result in methodname@## kind of names in the dll, that's why it needs special treatment.
Where does that AIInterface.dll come from anyways? (the one in the java interface folder), is that generated code by the awk script?
P.s. Ahh, right, I based my 'test' dll off the spring.exe code XD
I guess there's a generated wrapper .c code with all the methods in c for the Java interface :)
Still wonder where that code comes from and how it's built :D
Re: Java AI Interface for Spring
:D
well.. its all in the repo :D if you want to find out.
the interfaces are plugins, and since some weeks, they are really are modular, so the whole Java interface is under AI/Interface/Java, there is no special code outside of this, that does anything for the java interface (except the SCons build files, which are not interstign for you).
in the javaaispeed branch, a tiny part of the native sourcce of the interface is generated by an AWK script, and can only be found in the build directory, the main part of it is at src/native/, which uses the headers under rts/ExternalAI/Interface/*.h.
maybe you want to have a look at these gc flags for the linker:
well.. its all in the repo :D if you want to find out.
the interfaces are plugins, and since some weeks, they are really are modular, so the whole Java interface is under AI/Interface/Java, there is no special code outside of this, that does anything for the java interface (except the SCons build files, which are not interstign for you).
in the javaaispeed branch, a tiny part of the native sourcce of the interface is generated by an AWK script, and can only be found in the build directory, the main part of it is at src/native/, which uses the headers under rts/ExternalAI/Interface/*.h.
maybe you want to have a look at these gc flags for the linker:
Code: Select all
-Wl,--kill-at -Wl,--add-stdcall-alias
Re: Java AI Interface for Spring
Ahh, right, the generated C code is a new thing to support the direct jna stuff XDhoijui wrote::D
well.. its all in the repo :D if you want to find out.
And it would help if I'd actually -look at the branched source- XD
Ok, I see how it works now :)
Re: Java AI Interface for Spring
Finally a little more time to try with my 'test dll' :)
I found a way to still run the YourKit profiler with the direct mapping too, by disabling several things in the profiler options :)
Right now simple loops are more interesting though.
I'm still trying things, but one simple thing I found is that direct mapping can give -awesome- speed results. But only in certain cases :)
For example, Unit_getDef, which only gives a integer id as result:
- Callback method (this is what the current code uses I think, function pointers in a struct):
216 miliseconds for 40.000 calls.
- Old Mapping but no callback:
136 miliseconds for 40.000 calls.
- Direct mapping:
7 miliseconds for 40.000 calls.. Wow! :)
For methods like Unit_getPos the performance gain is much smaller, but this is because it has to create AIFloat3 objects, which is very costly. I'm gonna see if there's some ways to speed that up, mayby I should ask on the JNA forum now I've got some example code :)
*goes back to tinkering* :)
I found a way to still run the YourKit profiler with the direct mapping too, by disabling several things in the profiler options :)
Right now simple loops are more interesting though.
I'm still trying things, but one simple thing I found is that direct mapping can give -awesome- speed results. But only in certain cases :)
For example, Unit_getDef, which only gives a integer id as result:
- Callback method (this is what the current code uses I think, function pointers in a struct):
216 miliseconds for 40.000 calls.
- Old Mapping but no callback:
136 miliseconds for 40.000 calls.
- Direct mapping:
7 miliseconds for 40.000 calls.. Wow! :)
For methods like Unit_getPos the performance gain is much smaller, but this is because it has to create AIFloat3 objects, which is very costly. I'm gonna see if there's some ways to speed that up, mayby I should ask on the JNA forum now I've got some example code :)
*goes back to tinkering* :)
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
Re: Java AI Interface for Spring
getpos is one of the most critical functions for AI time, so if you can speed that up cranphin that would be awesome.
Random thought: what if the pos was passed as an array of floats insstead of a struct? Presumably one could prototype that quite quickly, not even using spring, just a simple 3 file, 50 line prototype to compare the different ways of passing data?
Random thought: what if the pos was passed as an array of floats insstead of a struct? Presumably one could prototype that quite quickly, not even using spring, just a simple 3 file, 50 line prototype to compare the different ways of passing data?
Re: Java AI Interface for Spring
https://jna.dev.java.net/servlets/ReadM ... &msgNo=737hughperkins wrote:getpos is one of the most critical functions for AI time, so if you can speed that up cranphin that would be awesome.
I've got some hopes for this, in 'call the method lots' tests the calculating of this size seems to hit pretty hard, so caching makes a lot of sense. Should see if we can't compile a jna ourselves really which does a prototype of that :)
Accidently posted it to dev isntead of users tho, doh XD
Don't expect magic tho! It's not gonna be amazing fast, but it should help :)
Yeah, I was thinking along those lines too, but not sure how much it will gain, worth trying though. Also was thinking if we could pass stuff by reference instead of by value. All kinds of ideas :)hughperkins wrote:Random thought: what if the pos was passed as an array of floats insstead of a struct? Presumably one could prototype that quite quickly, not even using spring, just a simple 3 file, 50 line prototype to compare the different ways of passing data?
Say, did you do windows or linux? You can have my little test projects :D
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
Re: Java AI Interface for Spring
linux. You?cranphin wrote:Say, did you do windows or linux? You can have my little test projects :D
Re: Java AI Interface for Spring
Doh! Yeah that'd be usefull info :)hughperkins wrote:linux. You?cranphin wrote:Say, did you do windows or linux? You can have my little test projects :D
I work on windows atm.
I can still give my test project tho, just means you'll have to do some porting :)
Mayby easier to write your own XD
Re: Java AI Interface for Spring
cool cranphin, nice you go on wiht it!
well.. i guess these findings are enough to justify merging the javaaispeed branch into master already. and.. good post on the JNA mailing list!
all good work!
well.. i guess these findings are enough to justify merging the javaaispeed branch into master already. and.. good post on the JNA mailing list!
all good work!

Re: Java AI Interface for Spring
Did some more posts on the JNA list :D
I've got the feeling JNA Structure is still somewhat immature, it needs cleaningup/fixing and optimizing/profiling. It could gain a lot of speed by caching information per Class I think :)
So, I've got hope the Java interface will still get faster, but I'm afraid we will have to be patient for the JNA guys :D
I've got the feeling JNA Structure is still somewhat immature, it needs cleaningup/fixing and optimizing/profiling. It could gain a lot of speed by caching information per Class I think :)
So, I've got hope the Java interface will still get faster, but I'm afraid we will have to be patient for the JNA guys :D
Re: Java AI Interface for Spring
Ohh, a suggestion btw.
Right now it looks like we run without the -server option:
";jvm.option.x=-server"
I think performance will benefit from using the -server option :)
Not 100% sure, but looking at descriptions of it I think it's better suited to our AI's.
In my very contrived tests I do so quite an increase in calls per second using '-server', but ofcourse that's not the best example, kinda hard ot measure it on a full AI though :)
Also I think it's a good idea to disable all the debugging options in jvm.properties for the next release, since people are starting to release proper AI's now and 'just players' will benefit from performance :)
(Well, the debug options that cost performance, but not sure which ones that are :D).
Right now it looks like we run without the -server option:
";jvm.option.x=-server"
I think performance will benefit from using the -server option :)
Not 100% sure, but looking at descriptions of it I think it's better suited to our AI's.
In my very contrived tests I do so quite an increase in calls per second using '-server', but ofcourse that's not the best example, kinda hard ot measure it on a full AI though :)
Also I think it's a good idea to disable all the debugging options in jvm.properties for the next release, since people are starting to release proper AI's now and 'just players' will benefit from performance :)
(Well, the debug options that cost performance, but not sure which ones that are :D).
Re: Java AI Interface for Spring
the default for 64bit is server already.cranphin wrote:Ohh, a suggestion btw.
Right now it looks like we run without the -server option:
";jvm.option.x=-server"
yeah... this might be a good point. I believe ot remember that SUN generally recommends using client on 32bit, but as we have a rather uncommon use of the JVM, you might be right there. Also, i agree wiht you that we should probably base this decission on a more realistic test then the ones you take here. For example, if it speeds up a non GUI AI by 1% but makes HughAI with its SWING GUI 50% slower, we might think again.
This has been dealth with already, if you have a closer look at the current jvm.properties file.cranphin wrote: Also I think it's a good idea to disable all the debugging options in jvm.properties for the next release, since people are starting to release proper AI's now and 'just players' will benefit from performance :)
(Well, the debug options that cost performance, but not sure which ones that are :D).
about the JNA guys:
maybe we could supply a patch. As i imagine it, this would be a very simple one, osmehow like:
Code: Select all
private Map<Class, int> classSizes = ...;
if (classSizeCaching && classSizes.containsKey(theClass)) {
return classSizes.get(theClass);
} else {
// calculate size as usual
classSizes.put(theClass, theSize);
return theSize;
}
then again.. i dont this this could ever be a problem, and surely is not for us (we would only have about 3 entries or so in this map).
checking how easy it isto get JNa source code...