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

World: r3wp

[!REBOL3-OLD1]

Steeve
9-Feb-2009
[10896]
>> dp []
== make object! [
    timer: 14
    evals: 8
    eval-natives: 3
    eval-functions: 1
    series-made: 1
    series-freed: 0
    series-expanded: 0
    series-bytes: 432
    series-recycled: 0
    made-blocks: 1
    made-objects: 0
    recycles: 0
]

see, a block is always created by dp
BrianH
9-Feb-2009
[10897x2]
If the block needs to be expanded because there isn't enough allocated 
the system does a block copy. If there *is* enough allocated, as 
when you preallocate using make block!, then the system doesn't have 
to do a block copy. That is R2 and R3.


What is new in R3 is that the "head" pointer of a block doesn't have 
to point to the beginning of  the allocated memory, just like the 
"tail" pointer in R2. This means a remove from the head of the block 
just shifts the pointer over one in R3, while in R2 you had to copy 
over the rest of the block contents to shift it towards the head 
of the allocated memory. Preallocated memory can also exist before 
the head of the block contents in R3. This means that there is no 
difference in overhead between inserts at the head or the tail of 
a block in R3.


In theory, inserts inside the block in the first half could be more 
efficient because you would only have to shift from the nearest end, 
not the tail. I don't know whether this optimization has been implemented.


Block operations in general could be faster because with no list! 
type we wouldn't have to special-case as much code, so we could make 
our code much faster through more aggressive optimization.


Btw, I submitted a tweak to DP to make it more accurate by subtracting 
its own overhead. It still has some variance though - have to tweak 
the native to fix that. Plus there is the extreme variance caused 
by Windows.
I hope this answers your question, Kaj.
Pavel
9-Feb-2009
[10899]
Back to map Brian's note words-of returns all keys is easy to overlook, 
but this is only way how to traverse thru map (when no next is at 
hand) THX Brian
BrianH
9-Feb-2009
[10900]
There is a proposal (looking likely to be implemented) to have FOREACH 
work on object! and map! types. The word list syntax would be restricted, 
but you could do your traversal that way. In the meanwhile you have 
WORDS-OF to get the keys in a block, VALUES-OF to get the values 
in a block, BODY-OF object! to get both in a block (map! proposed 
too) and TO-BLOCK of map! to get both in a block. It works, but the 
FOREACH proposal would create fewer intermediate blocks.
Pavel
9-Feb-2009
[10901]
THX again, is it possible something like "select" ie <,>,between 
etc?
BrianH
9-Feb-2009
[10902]
Of course FOREACH of map! would operate in the order that TO-BLOCK 
map! would return the keys and values at that moment. In the long 
run you would have to consider the order of FOREACH map! to be non-deterministic 
between calls. The map! type has no inherent ordering, so position 
and sorting are meaningless for it.
Pavel
9-Feb-2009
[10903]
hashed doesn't mean ordered?
BrianH
9-Feb-2009
[10904x2]
It doesn't. SELECT works on object! and map!, but there is no comparison 
except equality for those types.
Hashed means indexed (in the database sense), not ordered.
Pavel
9-Feb-2009
[10906x2]
my fault I missmatch rebol select with SQL like select
IE if you expect quite large number of keys would you have any chance 
to "narrow" like "sql between"
BrianH
9-Feb-2009
[10908]
Map! is not indexed in the REBOL sense, ironically enough: no position.
Pavel
9-Feb-2009
[10909]
OK now I have more clue, all this is toward key/value datastore preferably 
diskbased something I believe Paul is trying in R3
BrianH
9-Feb-2009
[10910x2]
REBOL is a lower-level language than SQL. No set operations (for 
map!, ar least). Those kinds of SQL operations need to be done procedurally 
in REBOL, using block copies and such.
We will have REBOL Indexed Files (RIF) for the disk-based datastore.
Pavel
9-Feb-2009
[10912]
I'm really currious believe me, like small boy
BrianH
9-Feb-2009
[10913]
Well, we don't havee RIF yet so you'll have to stay curious for a 
while :(
Pavel
9-Feb-2009
[10914x2]
I'm keeping finger crossed not to be too old to be able enjoy truly
But seriously thanks for all the job is done until now
Steeve
9-Feb-2009
[10916x2]
hmmmm.... interesting behaviour of blocks....

Brian, does that mean that Carl had in main a possibly new feature 
asked for a while: 

RANGE :A reference which is a sub part of an existing serie. (supress 
the need of overheaded copy/part in our sripts)

I think it's not at all tricky to implement if the head of a serie 
is a logical offset now.
(had in mind)
Pavel
9-Feb-2009
[10918x2]
Must be RIF native or is it possible to mimic in rebol as is now
is it question of mold load on each read?
BrianH
9-Feb-2009
[10920]
No, there are no plans to implement range. The head and tail of the 
series are attributes of the series, not the reference to the series. 
It's like the difference between the position attribute of a port 
and a series: For a series, the position is an attribute of the reference 
to the series, while for port, the position is an internal attribute. 
Still, a subseries reference could be implemented as a user-defined 
datatype as long as it is careful to make up for changes in the underlying 
series.
Oldes
9-Feb-2009
[10921x3]
I think that the idea was to be able store internal REBOL values. 
I mean that you for example close console with some defined values 
and after restart of the console you could load into the state where 
you ended.
At least I think Carl was somewhere talking about that. And that 
it could for example speed the boot time, which could be useful for 
cgi aps.
Correct me, if I'm wrong:)
BrianH
9-Feb-2009
[10924x2]
I am really curious to see how binding issues are resolved with RIF. 
You could just have the data come out of the RIF unbound...
Oldes, you are not wrong here.
Steeve
9-Feb-2009
[10926]
just to say the virtual-block scheme is an exemple of how RIF could 
be implemented (see http://sites.google.com/site/rebolish/for the 
source)
BrianH
9-Feb-2009
[10927x2]
Although Carl was actually talking about rebin to speed up the boot 
times, not RIF :)
RIF files were going to be binary (rebin), not source like Steeve's 
virtual blocks.
Pekr
9-Feb-2009
[10929]
Oldes - was it RIF? Wasn't it Rebin?
Oldes
9-Feb-2009
[10930]
Maybe it was rebin... all these far future projects:)
Steeve
9-Feb-2009
[10931x2]
Brian, i added the option to save the data as row binaries today 
in VBS
all other values are stored as molded values
BrianH
9-Feb-2009
[10933]
I saw that. Does it save all REBOL values in binary, or just binary!?
Steeve
9-Feb-2009
[10934x2]
except binaries
just binary!
BrianH
9-Feb-2009
[10936]
Still cool :)
Steeve
9-Feb-2009
[10937]
binaries are saved as-is (compact format), all other values are molded 
before being stored as binaries
BrianH
9-Feb-2009
[10938x3]
Rebin is intended to be a binary syntax for REBOL, like EBML for 
XML. All REBOL values (or maybe just the literal values) will be 
stored in a binary format. I suppose rebin would be an output format 
of MOLD and SAVE.
You would need something like RIF to restore the bindings though, 
since you could translate references to RIF indexes. In theory.
You would need a binary format to even have a way to store those 
references since REBOL syntax doesn't, even with MOLD/all.
Steeve
9-Feb-2009
[10941x2]
hmmm... the rebin format will be hudge, cause for series, there is 
2 indirections (2 references) + the value himself
am i wrong ?
BrianH
9-Feb-2009
[10943x2]
No, just the value and the reference to the value with the position. 
The poisition isn't a reference, just an integer (internally). So 
you need the series, the length of the series, a datatype tag, the 
reference to the series, and the offset. The reference and offset 
would be part of the contents of anotther series. It would take less 
space in binary than in memory or REBOL syntax.
I'm not sure that you're wrong though. There's also the index to 
consider.
Steeve
9-Feb-2009
[10945]
ahah.... i was near to argue you...:-)