World: r3wp
[Core] Discuss core issues
older newer | first last |
Steeve 24-Mar-2009 [13043x2] | *(can't fit) |
They are continous slots of course | |
BrianH 24-Mar-2009 [13045] | Are you referring to R2 or R3? R3's strings are different. |
Steeve 24-Mar-2009 [13046] | R2 |
BrianH 24-Mar-2009 [13047] | Right. |
[unknown: 5] 24-Mar-2009 [13048] | I'm curious why your saying it is 16 bytes. |
BrianH 24-Mar-2009 [13049] | Strings are preallocated in multiples of 16 bytes, probably to simplify the GC. |
[unknown: 5] 24-Mar-2009 [13050] | Oh this is a REBOL thing. |
Steeve 24-Mar-2009 [13051] | all values in Rebol are chunked into slots of 16 bytes length |
[unknown: 5] 24-Mar-2009 [13052x2] | Got ya. |
Seems a waste. | |
Steeve 24-Mar-2009 [13054] | all series data type are using continuous slots |
BrianH 24-Mar-2009 [13055] | Memory management. Even the stack is a block. |
[unknown: 5] 24-Mar-2009 [13056] | I'm just thinkg of the memory storage. It seems a waste from that persective. |
Steeve 24-Mar-2009 [13057x3] | we no that, it's a choice |
*we know | |
speed vs memory | |
BrianH 24-Mar-2009 [13060] | All memory management systems have a little waste. You have to balance the memory overhead versus the CPU overhead. |
[unknown: 5] 24-Mar-2009 [13061] | I'm not sure how it is faster. |
Steeve 24-Mar-2009 [13062] | its faster to handle blocks |
BrianH 24-Mar-2009 [13063] | It is faster to allocate in chunks because you don't have to reallocate as often. |
[unknown: 5] 24-Mar-2009 [13064] | I suppose Carl has something more being allocated then just the string data. |
BrianH 24-Mar-2009 [13065] | (bbl) |
[unknown: 5] 24-Mar-2009 [13066] | So I'm wondering where the length is stored at. I'm wondering if it is stored preceding the string data. |
Steeve 24-Mar-2009 [13067x2] | no, it's stored in another one slot, anywher in the mmemory |
by default, an empty string allocate 3 slots. 1 storing the logical address 1 storing the physical address and the length 1 storing storing the real data . These slots can be stored at any place | |
[unknown: 5] 24-Mar-2009 [13069] | interesting. But doesn't seem very efficient. |
Steeve 24-Mar-2009 [13070] | when a string is expanded, the data can be moved in another one place. So the physical address slot is updated, not the logical one |
[unknown: 5] 24-Mar-2009 [13071] | Well this is where I have the concern. Because at a lower level you would want to allocate memory for string large enough for certain variations of the string during runtime. And that approach seems to negate that possibility. |
Steeve 24-Mar-2009 [13072] | each reference on the same strings, have his own logical slot pointing on the same physical slot |
[unknown: 5] 24-Mar-2009 [13073x2] | Not negate it necessarily but make it less efficient asyou would have to allocate storage for the string each time on the new size. |
I'm obviously talking low level here and not what we have ability to do via REBOL. | |
Steeve 24-Mar-2009 [13075] | So basically, the string " " uses (16 * 3) = 48 bytes the char #" " uses 16 bytes Do your choice :-) |
[unknown: 5] 24-Mar-2009 [13076x2] | That seems crazy to me. |
I guess Carl has his reasons. | |
Maxim 24-Mar-2009 [13078x2] | actually all series store these pointers no? |
paul, rebol does mutable series. | |
Steeve 24-Mar-2009 [13080x2] | yest |
*yes | |
Maxim 24-Mar-2009 [13082] | there is no other way... you have to know the bounds, and allow ram to be recycled. indirection is the only way to do this. rebol has its own memory manager. |
Steeve 24-Mar-2009 [13083] | but new references on the same serie only consume a new slot of 16 bytes |
[unknown: 5] 24-Mar-2009 [13084x2] | Maxim, there are other ways. |
Maybe not in REBOL but there are in other languages for example. | |
Maxim 24-Mar-2009 [13086x3] | other languages do not use mutable series. they use immutable strings within a single index. every operation is a memcopy and then replace the pointer. |
and all references to a string are actually independant... change the string in varA and varB doesn't reflect it. | |
in rebol, they really are the same actuall string object. | |
[unknown: 5] 24-Mar-2009 [13089] | I'll have to learn more about mutable series verse immutable series. |
Maxim 24-Mar-2009 [13090x2] | python string objects, are comparable to rebol's series, but use immutable string internally, to be compatible with C. |
mutables actually make rebol harder to interface to most external code, cause we don't use the normal string end concept of terminating with a 0 char. | |
[unknown: 5] 24-Mar-2009 [13092] | So what do you mean when you say "mutable"? |
older newer | first last |