REBOL 3.0

Better DO performance

Carl Sassenrath, CTO
REBOL Technologies
21-May-2007 18:12 GMT

Article #0089
Main page || Index || Prior Article [0088] || Next Article [0090] || 4 Comments || Send feedback

As I mentioned earlier, the do function shifted from a native function to mezzanine in R3. This change was made to move higher-level code, such as do on an HTTP request, to REBOL code, not C. For example:

do http://www.rebol.com/test.r

The do overhead of this code is insignificant compared to the read overhead of the HTTP request itself.

But, do is polymorphic over all datatypes, so the above change meant that an evaluation as simple as:

do 1

would suffer the mezzanine evaluation overhead. As you would guess, that did not settle well with me...

So, I've reverted do back to being a native. This was made possible by the new system/intrinsic function dispatch methodology which is used for actions such as make on a port or module. It allows a native to call back into REBOL code for complex actions that are better off written at the higher level.

Here is a performance comparision for evaluating:

loop 1'000'000 [do 1]

on both R2 and both ways on R3:

REBOL 2.7 native 0.3 sec baseline
REBOL 3.0 mezzanine 2.4 sec 8 times slower
REBOL 3.0 native 0.125 sec twice as fast

Although do would rarely be put in a tight loop like this, it shows the benefit. The change was worth the effort (which was minimal anyway), and also retains the higher level do evaluation of URLs, files, etc. (And, that code can be customized by applications, as needed.)

An additional benefit is that the eval native becomes unnecessary. (And, I never liked that native.) Also, this change also allows removing the cause function for errors (becomes unnecessary).

4 Comments

REBOL 3.0
Updated 26-Dec-2024 - Edit - Copyright REBOL Technologies - REBOL.net