• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

DocKimbel
8-Mar-2013
[6058]
Better specify it clearly each time you announce comparative performances, 
else people will generalize it and get a wrong picture of the real 
performance ratios. 


Fibonacci basically tests the efficiency of the function calls. A 
test with a bigger loop could be interesting. For example, you can 
take the %demo.red script and strip all screen outputs, add a LOOP 
around the main code and  you'll should see much bigger differences.
Kaj
8-Mar-2013
[6059x4]
You know how it is with benchmarks: you can never specify it deep 
enough to prevent all caveats
So either the only specification is some salt, or you actually benchmark 
the readers to see who gets it and who doesn't
I don't know what "real" performance ratios are, but I think that 
computing Fibonacci numbers is a more real task than running the 
text console demo in a loop
I'd measure Mandelbrot performance, but Red can't do it ;-)
Paul
8-Mar-2013
[6063]
Kaj, good thanks for the update on the SDL problem.
Kaj
8-Mar-2013
[6064x2]
I'll test later if that's it
In any case, we just bought an XP machine for testing
Paul
8-Mar-2013
[6066]
Great, let me know what's next that you guys need help debugging.
DocKimbel
8-Mar-2013
[6067x2]
Paul: how can we reach you when we need some help?
Will you check AltME regularly now?
Paul
8-Mar-2013
[6069]
you can email me if need be at [ptretter-:-hotmail-:-com]
DocKimbel
8-Mar-2013
[6070]
Great, thanks.
Paul
8-Mar-2013
[6071]
yeah I'll be checking much more often now.
DocKimbel
8-Mar-2013
[6072]
Kaj, what matters in such benchmark is not the usefulness of the 
resulting data, it is how the test stresses the language implementation. 
From that perspective, Fibonacci just tests the efficiency of nested 
calls, nothing else, no series manipulation, no memory allocation, 
very limited math, very limited control flow, ... The demo code will 
stress more parts of the implementation, hence giving you a more 
accurate picture (closer to what user will experience with their 
own scripts).


If you take the language Shootout tests, each test is meant to stress 
a specific part of each language, giving a good (and quite fair) 
comparison for each category.


I think we should implement them in order to get a good picture of 
Red performances and how they evolve. Anyone interested in implementing 
them? http://dada.perl.it/shootout/
Kaj
8-Mar-2013
[6073]
Yes, so Fibonacci is a good such test, isn't it?
GrahamC
8-Mar-2013
[6074]
Looks like there are rebol versions there
Kaj
8-Mar-2013
[6075x3]
The Red interpreter can now actually load and run REBOL scripts, 
as long as they're compatible and they don't have a Unix shebang 
line
I could check for the shebang line in the console
Now that REDUCE is implemented, I suppose it's time for PRINT to 
reduce its argument?
DocKimbel
8-Mar-2013
[6078x4]
Fibonacci is a good such test, isn't it?
 It is a very good test for nested calls. :-)
PRINT: yes we could enhance it, but it would need to be promoted 
as a "keyword" in the compiler (not a big deal though).
I still have work on MOLD tomorrow, I'll try to do PRINT too.
There are also some refinements for some natives that are implemented 
in the compiler and not in the interpreter (/any for SET and GET 
from top of my head, but there are probably more). I need to do a 
review to collect them and implement them before the release (probably 
on Sunday).
Kaj
8-Mar-2013
[6082]
Are you sure PRINT can't just be a function?
DocKimbel
8-Mar-2013
[6083x3]
Yes, it is a function, but the reduction (on literal blocks only) 
could be handled by the compiler if it's also declared as a keyword 
(in the compiler).
Function => native
So `print [1 + 2]` could be compiled efficiently by the compiler 
(calling the native with a reduced block), while `print a` will directly 
call the native version.
Kaj
8-Mar-2013
[6086]
Would you have to do that with all functions that reduce?
DocKimbel
8-Mar-2013
[6087x2]
Currently, REDUCE and COMPOSE are handled like that by the compiler.
They have a native common part anyway, as some parts cannot be statically 
compiled.
Kaj
8-Mar-2013
[6089]
But REFORM etcetera?
DocKimbel
8-Mar-2013
[6090]
These less used functions could be implemented as mezz only.
Kaj
8-Mar-2013
[6091]
I'm not sure which are more performance critical
DocKimbel
8-Mar-2013
[6092x3]
It is not mandatory to make the compiler handle it, it will just 
produce faster code, as the expressions will be statically compiled 
instead of been interpreted.
It would be good to have some benchmarks on these to see the gains 
the compiler brings (it will be vary a lot I guess).
-be
Kaj
8-Mar-2013
[6095x2]
I don't see COMPOSE in the intrinsics
Shouldn't DO be an intrinsic, so it can compile literal blocks?
DocKimbel
8-Mar-2013
[6097x3]
Right, I've removed COMPOSE as an intrinsic, the implementation was 
too complicated and wasn't better than the purely native version.
DO: it was supposed to be handled by the compiler for literal blocks, 
but as it is the main way to invoke the interpreter, I wanted it 
to be consistent whatever argument was passed.
Also, later, I realized that if I make DO an intrinsic, expressions 
in functions like: `do [foo: :bar]` (where `bar` is a function) would 
be more complicated to write for the user, as the literal block would 
be compiled, loosing the advantage of interpreter here. So it would 
have required user to write instead: `code: [foo: :bar] do code`.
Kaj
8-Mar-2013
[6100x4]
Hm, intricate
So REDUCE is the most performant of all?
Andreas' R3 build is a bit slower even than mine, so nothing wrong 
with mine it seems. Apparently R3 is 10% slower than R2 on Fibonacci 
40
(On my machine, current constellation of the stars, etcetera, etcetera)
DocKimbel
8-Mar-2013
[6104x2]
:-))
Right, REDUCE on a literal block should be the fastest way to evaluate 
code dynamically, for now.
Kaj
8-Mar-2013
[6106]
Do you know of any other language that intertwines an interpreter 
and a compiler so intimately?
DocKimbel
8-Mar-2013
[6107]
No, not the way Red does it (static AOT compiler + interpreter), 
but as there are thousands of languages out there, I guess that there 
are probably others that use the same technique.


Thinking about that, there's a more classical approach used by some 
JIT compilers like LuaJIT, that by default runs under an interpreter, 
gather runtime stats, then starts replacing some nested loops with 
JIT-compiled code (principle of a tracing JIT). So, such architecture 
implies an interwined interpreter and JIT-compiler.