.:: Bots United ::.  
filebase forums irc server wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps waypoints yapb

Go Back   .:: Bots United ::. > Enhancement Workshop > Game Scripting (AMX, Small, etc.)
Game Scripting (AMX, Small, etc.) Where game engines and interpreters allow you to mess under the hood

Reply
 
Thread Tools
JIT seems to be very fast
Old
  (#1)
KWo
Developer of PODBot mm
 
KWo's Avatar
 
Status: Offline
Posts: 3,415
Join Date: Apr 2004
Default JIT seems to be very fast - 17-12-2004

Eveyone who says that small language is too slow in executing (and because of this he doesn't like it), look at the results of some benchmarks made by Bailopan.
For more details - what exactly is JIT - ask T(+)rget or Bailopan.

http://www.tcwonline.org/~dvander/bench.htm
   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#2)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: JIT seems to be very fast - 17-12-2004

I know that JIT can be fast, since that's why it's been introduced, anyway this benchmark doesnt tell me anything. I mean, why should Assembler be slower than JustInTime compiled stuff ? I mean, they have to do the same work, and for example floating point ops don't rely if it's native written ASM or called by some JIT code, the execution time is the same. Ok, if this benchmark wants to show that the JIT compiler is able to do optimizations, ok. but why dont you optimize the ASM code then ...

or is that interpreted asm ?



Last edited by @$3.1415rin; 17-12-2004 at 10:28..
   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#3)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 4643'60N 043'0W 0.187A
Default Re: JIT seems to be very fast - 17-12-2004

interpreted ASM ? I subsmell a good dose of irony here



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#4)
BAILOPAN
Member
 
Status: Offline
Posts: 5
Join Date: Aug 2004
Location: RI
Default Re: JIT seems to be very fast - 18-12-2004

AMX/Small bytecode is a block chunk of memory, split into one cell (4 or 8 bytes) per opcode and another for each parameter. Each opcode takes one parameter, except for debug opcodes which can take multiple parameters.

There are four ways of executing this bytecode.

Normal: Each cell is read and interpreted at face value. Jumps/calls are relative addresses, opcodes are interpreted through a huge case/switch table.

GCC/Linux: GCC has a label addressing feature, so beforehand all of the opcodes are browsed and relocated to be physical addresses of a big list of labels... this means opcode interpretation is direct instead of a switch statement, and gives about a double speed increase on Linux.

ASM: The assembly method is the GCC method, except opcode interpretation is in x86 assembly instead. The opcodes are physical address jumps into assembly procs that handle the parameters.

JIT: The JIT is something quite different. It pre-processes the bytecode and does AOT (ahead-of-time compilation):
1. Reads an opcode (say, PUSH.PRI)
2. Copies a few assembly instructions which perform this to garbage data.
3. Copies the opcode parameters over the garbage.
4. Finds the next opcode and goes back to 1.
5. When done, it has destroyed the original bytecode and replaced it with native x86-assembly.
It also relocates all jumps/switches/etc to physical addresses. Further execution is simply jumping into the code, rather than using amx_Exec()'s bytecode interpreter.

This means the JIT takes all of the AMX bytecode and outputs optimized assembly which accomplishes the same thing. And because it has NO interpreted jumps or opcode switched (unlike the others) it's lightning fast. It also ignores all debug opcodes when compiling for speed - on AMXx I wrote a feature where you can have it keep these so you can debug properly, but it's optional.

On my tests the JIT was usually 10-12 times faster than normal bytecode.

KWo asked me to clear this up, I hope it helps
   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#5)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: JIT seems to be very fast - 18-12-2004

yes, ok, this is about the bytecode only. no comparision to how fast this would be if compiled using C/C++


   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#6)
BAILOPAN
Member
 
Status: Offline
Posts: 5
Join Date: Aug 2004
Location: RI
Default Re: JIT seems to be very fast - 18-12-2004

I think you misinterpreted what I wrote. That IS the comparison:

Normal: AMX bytecode, C interpreter.
ASM: AMX bytecode, ASM interpreter.
JIT: x86 native code, CPU executes.
   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#7)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: JIT seems to be very fast - 18-12-2004

yep, somehow I don't get it.

just pick the "Normal" case : the AMX bytecode is translated to C and then compiled and executed ? or is this C code then interpreted ? since you wrote "C interpreter" ...

why not compile the AMX bytecode to native machine code and then execute it ? why do you need JIT ? JIT is useful with java e.g. to have optimal performance on different systems, but if you just want it to run on some x86 compatible system, where is the advantage over compiled code ? Or should I think more about the Transmeta approach and codemorphing to archieve better performance from already compiled code ? the worst point in the benchmark is the math stuff I already pointed out. feeding the CPU using some native code should be the fastest way possible, since JIT is basically the same ... why should that be faster. but as I said, somehow I dont get it what's the categories in the benchmark about, even with your explanation, sorry


   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#8)
BAILOPAN
Member
 
Status: Offline
Posts: 5
Join Date: Aug 2004
Location: RI
Default Re: JIT seems to be very fast - 23-12-2004

If you still don't get it at this point there's not much I can do for you ;]

Quote:
Originally Posted by @$3.1415rin
just pick the "Normal" case : the AMX bytecode is translated to C and then compiled and executed ? or is this C code then interpreted ? since you wrote "C interpreter" ...
The bytecode is never translated to C. The bytecode is interpreted by an interpreter written in C (and none of this was written by me).

Quote:
Originally Posted by @$3.1415rin
why not compile the AMX bytecode to native machine code and then execute it ? why do you need JIT ?
That is exactly what the JIT does. Technically, I said earlier you could make the distinction that AMX JIT is actually an AOT (Ahead of Time compiler) but I won't because the author calls it a JIT.

Java's JIT is supposedly an AOT as well... Microsoft's .NET has a true JIT wich compiles certain portions of bytecode on the fly, as it analyzes the code as its running and is able to make specific optimizations.

I may be wrong about Java, but there you have it.
   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#9)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: JIT seems to be very fast - 23-12-2004

I wonder how you would go about writing a JIT. I would love to make an emulator.


sfx1999.postcount++
   
Reply With Quote
Re: JIT seems to be very fast
Old
  (#10)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 4643'60N 043'0W 0.187A
Default Re: JIT seems to be very fast - 23-12-2004

<TROLL>

Wouldn't it have been more straightforward, I would even say... more "common sense compliant", to write your plugins in trusty old C, or whatever C++ if you absolutely want it, and include a free C compiler (Watcom, Borland, Microsoft's command-line CL, or the other one there, GNU) that would compile them on the fly each time the server is started ?

It takes about 3 seconds to compile a medium-sized metamod plugin. Performance wise, it's unbeatable. And already debugged. You have nothing to worry for. Man...

</TROLL>



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
   
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com