r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Will
25-Jan-2009
[12188]
I'm on 2.7.6 os x , symtom is rebol just goes mad using up 100% CPU 
and never quits , using "ktrace -p processid" generate an empty ktrace.out
Oldes
25-Jan-2009
[12189x2]
And how do you start the script? Do you use -cs switch?
Because call is asking security question if you don't run rebol with 
at least -s switch
Will
25-Jan-2009
[12191x2]
-qs, the problem is when doing a ctrl-c on running cheyenne (not 
always, mostly after some load) traying hard to have a 100% repoducible 
code but nothing yet, hard
not even sure the problem is with call, what is sure is cpu goes 
full, the dns help process quit ok, ktrace on that process return 
nothing
Oldes
25-Jan-2009
[12193x2]
I'm testing it now with cheyenne and it seems not to be working... 
even if I do:
	print "Content-type: text/html^/"
	tmp: copy ""
	call/output/wait "dir" tmp
	probe tmp
CPU is fine here.. just the output is missing and there is error:
Error Code :  	300
Description : 	script error !
tmpnone has no value
Near : 	[probe tmpnone]
Where : 	protect-code
Will
25-Jan-2009
[12195]
sorry I may have been more clear, the code is in uni-engine.r, this 
line:

call/show join form to-local-file system/options/boot [" -qs " cmd]
not in a RSP, and not sure at all the problem is with call... 8/
Oldes
25-Jan-2009
[12196]
the above is not in RSP either.. it's as a cgi script. Cheyenne is 
not only RSP:)
Will
25-Jan-2009
[12197]
ok, thank you, now I need a guru with some tips on how to track down 
the issue.
BrianH
25-Jan-2009
[12198]
More backports: AJOIN

ajoin: func [
    "Joins a block of values into a new string."
    block [block!]
] [
    head insert copy "" reduce block
]


AJOIN is native in R3 and doesn't generate an intermediate block 
(it reduces in place), but even in R2 it has advantages:

- It always returns a string, no matter what the type of the first 
value in the block is.
- It is faster than REJOIN.
[unknown: 5]
25-Jan-2009
[12199]
Might change the description a bit to say that is reduces the block. 
 "Reduces a block of values and joins them into a new string."  Reducing 
is a security concern so we might want to ensure whoever uses the 
function is aware of this.
BrianH
25-Jan-2009
[12200]
Since that is the doc comment of the R3 version I will submit that 
concern as a trouble ticket in CureCode.
Dockimbel
25-Jan-2009
[12201x2]
Brian, in AJOIN, why not prefer the use of [make string! 0] instead 
of [copy ""] so that REBOL don't need to allocate a literal string 
to be used only as a prototype? That would reduce memory usage by 
one string buffer allocation.
I guess that memory usage is a high concern in mezzanines.
BrianH
25-Jan-2009
[12203x2]
COPY "" is faster than MAKE STRING! 0 (amazingly enough), and you 
don't have to allocate a literal "" every time, just once at LOAD 
time
Speed is a bigger concern for mezzanines, but there has to be a balance. 
We are doing more advanced tricks in R3 to increase speed and reduce 
memory overhead, but R2 is in bugfix and backport only mode right 
now.
Gabriele
26-Jan-2009
[12205]
Brian, did you compare with make string! reduce ? It may be faster.
DideC
26-Jan-2009
[12206x2]
In R3  (R2 is a very small bit faster, but I guess its related to 
the console) :

>> t: now/time/precise loop 1000000 [copy ""] print [t - now/time/precise]
-0:00:00.203

>> t: now/time/precise loop 1000000 [make string! 0] print [t - now/time/precise]
-0:00:00.25
Not a big difference if you consider 1'000'000 loop !
Oldes
26-Jan-2009
[12208]
I'm using this version:
ajoin: func [

    {Faster way how to create string from a block (in R3 it's native!)}
    block [block!]
][to string! reduce block]
[unknown: 5]
26-Jan-2009
[12209x2]
It is better Oldes.
There might be a reason why Brian didn't go that route.
BrianH
26-Jan-2009
[12211x3]
Oldes, I can't find any compatibility differences, so that should 
be fine. Use MAKE instead of TO though - it's faster.
TO does weird conversion stuff so it is slower than MAKE (which does 
*less* weird conversion stuff).
Paul: I was tired yesterday, which was why I didn't do enough optimization 
- that's the reason :(
[unknown: 5]
26-Jan-2009
[12214]
I'm not complaining Brian.  I always do the same.  Which is why it 
is always best to present mezz type of functions ot the community 
for scrutiny before they go into any builds.  Just a wise way of 
doing things.
BrianH
26-Jan-2009
[12215x2]
That's why I posted it here before I posted it in DevBase :)
Wierdly enough, the make string! reduce block version of AJOIN is 
slightly faster in R3 than the native AJOIN, though it does have 
that intermediate block overhead - AJOIN could use some optimization. 
Who said mezzanines had to be slow?
[unknown: 5]
26-Jan-2009
[12217x2]
heh
Yeah, I would think we would want to change that then in R3 so that 
a mezzanine is not performing faster than native code.
Dockimbel
26-Jan-2009
[12219]
Side effect of slow interpreter loop and fast natives.
BrianH
26-Jan-2009
[12220]
The other way around, Doc. Mezzanines are not slow. It all depends 
on what the function is doing. Most of the time any interpreter overhead 
is dwarfed by the work the code is doing. This is why REBOL can be 
so fast when do much of it is written in REBOL.
Dockimbel
26-Jan-2009
[12221]
Right for R3 AJOIN exception, other way around.
Gabriele
27-Jan-2009
[12222]
BTW DideC, if you use now/precise instead of now/time/precise and 
use difference instead of - then you don't have a problem around 
midnight.
DideC
27-Jan-2009
[12223x2]
...or just avoid benchmarking arround midnight ;-)
Thanks for the advice anyway.
Will
27-Jan-2009
[12225x4]
good tip Gabriele, thx
about my problem (a couple of messages above) I can confirm that 
the problem doesn't exist with 2.7.5.

2.7.6, supposedly fixed [call] but did it introduce a new bug? has 
it maybe to do with hevy cpu, timing, rebol dns helper process?
I'm having a hard time producing code that reproduce the bug, if 
anyone can provide a piece of code that could stresstest [call] I'd 
be gratefull! 8)
or a problem with the GC upon quit when there are many words ?
[unknown: 5]
28-Jan-2009
[12229]
I posted a new function in the mezzanine thread at the Tretbase REBOL 
forum http://www.tretbase.com/forum/viewtopic.php?f=8&t=30&p=130#p130
Sunanda
28-Jan-2009
[12230]
Nice start,  Paul, to pulling the teeth of code you do not want to 
execute

I think you need to handled action!s too, otherwise some executable 
code can slip by:

>> defunction [abs trim change make select remove sort]   ;; etc, 
anything that is an action!
== [abs trim change make select remove sort]
[unknown: 5]
28-Jan-2009
[12231]
It is an easy modification but I actually made it to allow actions 
as I was using it briefly for that purpose.
[unknown: 5]
29-Jan-2009
[12232]
Posted the get-block function to the mezzanine thread on the Tretbase 
forum http://www.tretbase.com/forum/viewtopic.php?f=8&t=30&p=131#p131
Josh
30-Jan-2009
[12233]
Is there a simple way to convert a char number to the actual integer? 
(i.e. to-integer #"5" giving 5 as a result)
Izkata
30-Jan-2009
[12234]
I usually go with:  to-integer to-string #"5"
Josh
31-Jan-2009
[12235]
Thank you
Henrik
31-Jan-2009
[12236]
>> to-integer form #"5"
== 5

Saves a couple of chars :-) (but profile it, it might be slower)
Chris
31-Jan-2009
[12237]
to-integer #"5" - 48