World: r3wp
[!REBOL3]
older newer | first last |
Steeve 13-Dec-2010 [6532] | As far I remember It's working with R2 if you write the %file past the end, it's filled with #{00]. I remember having asked the same feature in R3 one year ago at least (in the R3 chat) |
Oldes 13-Dec-2010 [6533] | Are you sure it must be in one file? |
BrianH 13-Dec-2010 [6534] | Thanks again, Jerry, for pushing the resource usage limits of R3. http://issue.cc/r3/1799is about reallocating a 256+ MB map! to an even larger map!, and then getting a slowdown probably because of virtual memory use. We really need tasks so this can go on in the background :) |
Andreas 13-Dec-2010 [6535] | More likely a 512+MB map. |
BrianH 13-Dec-2010 [6536] | I think the problem was a realloc from 256+MB to 512+MB, which would temporarily have 768+MB in memory, plus a hash table recalculation. |
Andreas 13-Dec-2010 [6537] | If a single R3 value slot is 128bit and a map needs two value slots for each (key, value) pair: (128 / 8) * 2 * (2 ** 24) / (1024 ** 2) == 512.0 |
BrianH 13-Dec-2010 [6538x2] | Weird, I did a similar calculation and got 256. I should revise my comment. |
Oh right, I put a 16 in there when it should have been a 32. | |
Maxim 13-Dec-2010 [6540] | so should maps allow to be pre-allocated like series? |
Andreas 13-Dec-2010 [6541x3] | They are already. |
m: make map! n | |
Well, at least that allocates _something_ :) | |
Maxim 13-Dec-2010 [6544] | hehe |
Pekr 13-Dec-2010 [6545x2] | :-) |
So is it about the initial sufficient prediction of programmer allocating enough of memory, or is there some artificial limit for the map size? | |
Maxim 13-Dec-2010 [6547x2] | its about the fact that some things have to be arrays in ram, and if you don't make them big enough to begin with eventually, you have to live with this sort of "cleanup' |
REBOL didn't crash so I'd assume it did its job correctly. but a few tests might prove that something is not optimal. | |
Pekr 13-Dec-2010 [6549] | Why do guys need so large map array? Don't you remember Bill Gates once said, that 640KB is enough for everyone? :-) |
Maxim 13-Dec-2010 [6550x3] | this seems to prove that pre-allocating maps does indeed store all the space required: >> stats == 921576 >> m: make map! 20000000 == make map! [ ] >> stats == 909353688 |
Jerry, you might want to try the above and see if the wait occurs on the 21 millionth item. | |
(20 millionth item + 1) | |
Andreas 13-Dec-2010 [6553] | I'm with Brian in that most likely the only thing "not optimal" is the amount of RAM in Jerry's system. |
Maxim 13-Dec-2010 [6554x2] | yep! |
if the pre-allocation fixes the setup. then there's no bug in REBOL. | |
Andreas 13-Dec-2010 [6556] | Preallocation won't help with insufficient memory :) |
Pekr 13-Dec-2010 [6557] | moving to SSD disks might help a bit :-) |
BrianH 13-Dec-2010 [6558] | Well, it would, actually. It would still be slow to use, but not as slow. Reallocation takes even more memory. |
Andreas 13-Dec-2010 [6559] | Yes, of course. |
BrianH 13-Dec-2010 [6560] | This is assuming virtual memory. I wouldn't even be able to test on this system; it only has 1GB of RAM. My main system would work though. |
Andreas 13-Dec-2010 [6561x3] | I was hinting at the fact that this probably won't matter much if we are talking about a 512M system :) |
>> dt [m: make map! [] repeat i to-integer 2 ** 24 [poke m i i]] == 0:01:22.254896 ;; 2393MB resident | |
>> dt [m: make map! n: to-integer 2 ** 24 repeat i n [poke m i i]] == 0:00:48.329933 ;; 1026MB resident | |
BrianH 13-Dec-2010 [6564] | I suggested preallocation in a comment. You might want to chime in with that code :) |
Andreas 13-Dec-2010 [6565] | I would probably make it significantly large than the number of expected pairs. |
BrianH 13-Dec-2010 [6566] | Round up :) |
Andreas 13-Dec-2010 [6567x3] | ;; Storing 2^24 in a map with 2^25 preallocated >> dt [m: make map! to-integer 2 ** 25 repeat i to-integer 2 ** 24 [poke m i i]] == 0:00:33.695578 ;; 1538MB resident |
~30% faster. | |
Still incredibly slow. | |
BrianH 13-Dec-2010 [6570] | Are you doing those measurements in a fresh console each time? Remember, process allocation from the OS matters too. |
Andreas 13-Dec-2010 [6571] | Yes :) |
BrianH 13-Dec-2010 [6572] | Figured :) |
Andreas 13-Dec-2010 [6573x6] | With speedstepping switched off and the REBOL process pinned to a single core. |
And ... | |
What antagonist language of the day do we want to counter-benchmark? | |
Let's go with Python. | |
~10 times faster (without pre-allocation). Well ... | |
Guess there's some room for improvement :) | |
BrianH 13-Dec-2010 [6579] | How fast without the repeat, but with preallocation, comparing Python and R3? Remember, Python is compiled. |
Andreas 13-Dec-2010 [6580] | Bytecode compiled, with a really slow VM. |
BrianH 13-Dec-2010 [6581] | Bytecode compiled is still compiled, and it is likely that bytecodes specific to loops are being used. I am interested in the comparison of the preallocation of the map! type versus the Python equivalent, whatever that is. |
older newer | first last |