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

World: r4wp

[Rebol School] REBOL School

Ladislav
22-Mar-2013
[1822]
(instead of "explanations")
Maxim
22-Mar-2013
[1823]
have you tested how much overhead it causes on evaluation?
Ladislav
22-Mar-2013
[1824x3]
As I said, it depends on the implementation, which may need more 
optimizations...
(I wrote only a mezzanine "template", and suggested some tricks, 
but Carl wrote the actual implementation using my hints)
Did you test it?
Maxim
22-Mar-2013
[1827]
cause in my tests, binding is the single most demanding (low-level) 
operation for the interpreter.  I am not trying to debunk your efforts 
for closure, which *should* be used more, I am just curious as to 
the impact it causes in real life.
Ladislav
22-Mar-2013
[1828x4]
OK, any test results?
As I mentioned, I already gave Carl an advice how to speed up binding 
in R3 substantially when compared to R2
...and I know he used my advice obtaining a noticeable improvement
OTOH, there is still one trick that can be used to speed up rebinding 
in closure case.
Maxim
22-Mar-2013
[1832]
testing of binding itself on class vs prototype based oop for Rebol 
was several orders of magnitude when dealing with large objects. 
 both in speed and RAM.  I admit my tests are more on the extreme 
side of things, with the object in question taking up 80kb of RAM 
for every new instance.


but when grouping up the functions of the object into a "sub" object, 
like face/feel, instead of letting them live within the face itself, 
speedup was exponential.

at 1000 objects it was probably about 10 times faster, at 10000 objects 
it was about 25 times faster and I couldn't even allocate 100000 
prototype objects and it crashed after a full 76 minutes of crunching 
at 100% CPU.  a 1'000'000 object test with "classes" took 4 minutes 
and 400MB... so you can see that binding is a very significant part 
of the processing of Rebol, when it is required often.


obviously, some peeking into the C sources will allow us to optimize 
all of this, (especially if it can be memcopied directly)  but by 
default, as in R2, closures would theoretically be quite a hit in 
performance.
Ladislav
22-Mar-2013
[1833]
So, obviously, totally unrelated tests.
Maxim
22-Mar-2013
[1834]
related, tests which show that run-time rebinding must be avoided 
at all costs.   if closures are forced to rebind, there will be a 
hit.


my question was initially to know if you had done tests with closure 
itself... cause I  am curious how well it compares to the default 
case of doing it all on the interpreter side.
Ladislav
22-Mar-2013
[1835]
I see no point in:


- testing in R2 where the native implementation of closure does not 
exist

- testing in R2 where the binding algorithm is substantially slower

- using test R2 results for faces to infer about R3 implementation 
of  closures
Andreas
22-Mar-2013
[1836x4]
R3 A111 / Linux-x86:
>> f: func [x y] [x + y]
>> dt [loop 1'000'000 [f 10 20]]
== 0:00:00.18006
>> q
>> c: closure [x y] [x + y]
>> dt [loop 1'000'000 [c 10 20]]  
== 0:00:00.882204
R3 master, current rebolsource.net build for Linux-x86:

>> f: func [x y] [x + y]
>> dt [loop 1'000'000 [f 10 20]]
== 0:00:00.158908

>> c: closure [x y] [x + y]
>> dt [loop 1'000'000 [c 10 20]]
== 0:00:00.279227
Well, stupid measurements, sorry. The A111 measurement is an outlier. 
Need to do more statistically sound measurements.
f: func [x y] [x + y]
c: closure [x y] [x + y]
loop 30 [
    print [
        dt [loop 1'000'000 [f 10 20]]
        dt [loop 1'000'000 [c 10 20]]
    ]
]

R3 A111 Linux-x86:
function: 0.16014277 avg
closure: 0.29911023 avg
86.7% +/- 1.6% difference at 99.5% confidence (t-test)
AdrianS
22-Mar-2013
[1840]
It would be interesting to see how that difference varies as the 
complexity of the body increases.
Ladislav
22-Mar-2013
[1841]
Here is an example with a complex body:

f: func [n x y] [
	loop n [
		loop n [
			loop n [
				x + y
			]
		]
	]
]

c: closure [n x y] [
	loop n [
		loop n [
			loop n [
				x + y
			]
		]
	]
]

>> time-block [f 10 10 20] 0,05
== 0.00017675781250000002

>> time-block [c 10 10 20] 0,05
== 0.000158203125
AdrianS
22-Mar-2013
[1842]
the closure is more efficient?
Ladislav
22-Mar-2013
[1843]
Yes
Ladislav
23-Mar-2013
[1844]
See also

http://issue.cc/r3/1946



to note that there is almost no limit how much more inefficient can 
R3 functions be compared to closures. This is unacceptable taking 
into account that R3 functions purportedly are a "compromise solution" 
sacrificing correctness, reliability, comfort for speed.
GiuseppeC
23-Mar-2013
[1845]
Is the "Bindology" article still valid for R3 ?
Ladislav
23-Mar-2013
[1846]
Well, changes exist. It is useful to read it even when trying to 
understand how it is supposed to work in R3. It would be better to 
update it for R3, though.
SWhite
4-Apr-2013
[1847]
OK, now I know the answer and it is time to confess it.  I have complained 
a number of times about how obscure REBOL is (to me) and how I sometimes 
can look at ONE LINE of code and not understand it. I wonder, is 
it REBOL, or is it me.   Well, I am learning python for work, and 
I want to replce the html lt and gt symbols with their character 
entities or whatever they are called, I found a sample on the internet, 
wrote up a test program, copied the sample, and it worked.  So here 
I am looking at ONE LINE of python code and I don't understand how 
it works.  So, the answer to, is it REBOL or is it me, is, IT'S ME. 
 I think I'm in the wrong line of work.
Gregg
4-Apr-2013
[1848]
It all depends on the line of code Steven. :-) Still, if there's 
something you enjoy more, that makes you feel like it clicks in your 
head, do that.
Arnold
4-Apr-2013
[1849x3]
In most languages it is possible to do things in one line. Very often 
the result is that it is hard to understand what happens in that 
line. In the light of maintainable code I have the attitude that 
I rather deal with less comlicated code that is possibly a little 
slower. If that is not an option (most of the time performance stays 
way within limits even if it is readable) then I leave a big comment 
what the code is about. For sure the next guy/girl will appreciate 
this when it is their turn. There have been many occasions that I 
myself was the assigned the next adaptations and only a few months 
later these comments really were helpful.
Some guys are wizzards, but they do not take into account the maintainability 
of their code by others. Real wizzards make good clear readable code.
And leaving complicated code without comments because you understand 
it (at the moment of creating the code) is also bad practice. As 
a professional coder I comment a lot, maybe because sometimes it 
is not appealing to come back later for more headaches from bad coding 
practice from colleagues ;)
Ladislav
4-Apr-2013
[1852]
I sometimes can look at ONE LINE of code and not understand it

 - it can happen to anyone of us (at least I do not have any problem 
 to admit it happens to me as well) I just don't give up in such case 
 knowing that I will be rewarded if I find out what it is I am not 
 seeing
Endo
5-Apr-2013
[1853]
No, SWhite, it's not you! it's me! :)
Marco
6-Apr-2013
[1854]
@SWhite: I think it happens to all of us. If you know what that ONE 
LINE does try to do it in as many lines you prefer and then try to 
shrink those lines to only one and maybe you will end up with that 
ONE LINE !
caelum
14-Apr-2013
[1855]
Does anyone know where I can find the '%gui.r' in the 'do %gui.r' 
line of this program?

http://reb4.me/r/arrow-RebGUI-port


I have searched Christopher Ross-Gill's website and don't see it 
or where to find it.
GrahamC
14-Apr-2013
[1856]
Was that the abortive View development?
caelum
14-Apr-2013
[1857]
Don't know. The program dates back to 2005. Was that when the 'abortive 
View development' happened?
NickA
14-Apr-2013
[1858]
Chris is still active here - have you tried PMimg him?
caelum
14-Apr-2013
[1859]
Yes, I left a message for him. But he has not been here for a couple 
of months.
GrahamC
15-Apr-2013
[1860]
Here's usually now found on http://chat.stackoverflow.com/rooms/291/rebol-and-red
Artful
23-Apr-2013
[1861]
ok silly newbie question here.  I'm trying to run some scripts in 
rebol/view 2.7.8 which produce just console output.  I'm finding 
the output window automatically closing when the script ends.  I 
know I could fix this with a readline statement, but I'm wondering 
why the auto-close in prefs.r isn't working for me.  I'm also trying 
to run same script via dos window, using rebol.exe -ws test.r  but 
that opens an output window rather than display to the dos window. 
 I feel such a noob lol.
Gregg
23-Apr-2013
[1862x2]
Not to worry. We were all noobs once. REBOL automatically quits at 
the end of the script. If you want to keep the cosole open, put a 
HALT at the end.
REBOL, under Windows, uses its own GUI "console" window, so you have 
to trick it. Running it in CGI mode should work for you.
Artful
23-Apr-2013
[1864]
aha  ok, thanks.  I knew it was something simple.
Gregg
23-Apr-2013
[1865x2]
With REBOL, it's almost always something simple. Until you drop into 
the deep water. :-)
But someone is usually here to throw you a life preserver.
Artful
23-Apr-2013
[1867x2]
yes I am pleased the community is still going strong.
so any difference to script execution if cgi mode is used? besides 
the no output window
Gregg
23-Apr-2013
[1869]
Shouldn't be. Doc or other experts might know of subtlties though.
Endo
24-Apr-2013
[1870]
>> x: next [a b]  USE x [a: 1]  print a
** Script Error: a has no value

Why USE make 'a local on above example while X is [b] ?
Gregg
24-Apr-2013
[1871]
It works correctly under R3. R2 is obviously using the head of the 
series. You can work around it by using COPY before NEXT.