<tabemann_>
whereas my memory pool has a minimum block size of 4 bytes
<tabemann_>
with no extra overhead
<tabemann_>
the only issue with the memory pool is that each block has a fixed maximum size, and if less data is needed than the full block size it is wasted
<tabemann_>
*the remainder is wasted
<veltas>
Yeah I think you're trying to square a circle a bit on this one
<tabemann_>
note that the heap can be combined with the memory pool, as the user can take space allocated on a heap and add it to the memory pool
<tabemann_>
and that was my objective here
<veltas>
You can avoid storing the size per-block if the size can be passed to free and the actual size is a deterministic function of requested size
<veltas>
And if you are freeing something you generally either know or can remember how large it is
<veltas>
It's been talked about that this is a 'broken' feature of C, C++ etc that free/delete does not pass size info (in C++ it really is, because classes absolutely know how large things are)
<veltas>
This saves like 16 or 8 bytes per allocation on modern computers.
<tabemann_>
I'm surprised that you actually implemented a compacting heap for a ZX Spectrum, btw
<veltas>
I didn't!
<veltas>
I said I started doing it and gave up because it turned out not to be worth it :P
<veltas>
It might be worth it on an embedded device with very constrained RAM where the flash space is not an issue
* tabemann_
notes that the Mac had a compacting heap originally
<veltas>
If you find yourself writing extra code to try and save space in the same space you're trying to save, you're doing it wrong
<veltas>
Yes Mac and Windows both
<tabemann_>
compacting heaps make it hard to write bug-free code though
<veltas>
On Windows it 'hid' the details from you often because it would compact on a 64K boundary, and your segment registers would get mysteriously updated if it happened while your program was yielded
<tabemann_>
because you need to keep on locking and unlocking blocks
<veltas>
Yes, this is what I realised and that adds extra code, therefore the space lost by fragmentation is not as bad as the space (from extra code) *and* effort required by the compacting
<veltas>
It would be worth it on e.g. x86 where you can hide the details like MS did
<veltas>
Why would you be surprised?
<tabemann_>
?
<tabemann_>
oh yeah
<tabemann_>
I thought that the ZX Spectrum would be too small of a system to really support something like a real heap, with its overhead
<veltas>
Definitely was constrained, heap is convenient though and I was writing a text editor so seemed worth it
<veltas>
Had an array of pointers to text lines, means the line length can be more flexible and probably more memory efficient than what forth does
<veltas>
Old Forth block editors just allocate the whole block to a number of fixed-length lines, short lines waste loads of space etc.
<tabemann_>
yeah
<veltas>
The thing wasting space on that project was trying to write code in C with SDCC
<veltas>
The idea was to try and make an interactive environment with some kind of language, and I decided then that it would actually make more sense to create a small language and implement the *editor* and as much as possible in that language
<veltas>
Even write the compiler and interpreter in the language, all you need then is to write the VM in machine code
<veltas>
This is before I knew forth obviously, or the solution would have been painfully obvious
<tabemann_>
yeah
<tabemann_>
okay, I'm gonna have dinner now, will bbl
<veltas>
I like rediscovering all the same problems others have solved
<tabemann_>
definitely
<veltas>
Have fun
<veltas>
I think the right way to do a text editor with constrained space is to delimit lines where they are allocated, and leave space between them. Then you can compact if needed, or shuffle them along (less frequently than if they're all bunched up)
<veltas>
The actual BASIC environment that comes with the Spectrum decided to delimit them in memory all contiguously, and then as lines are inserted all further lines must be moved along in memory, which is visibly slow in the editor!
<veltas>
The Spectrum fit a decent amount of code in, because it was stored tokenised, values above $80 were used for keywords/built-ins/etc
<veltas>
Just put everything in B-trees with traversal optimisations and then use a fixed-size pre-allocated pool for allocations, fully real-time. Just don't ask me to code the B-tree :P
_whitelogger has joined #forth
<TangentDelta>
It's annoying that the 6502 took off and became super popular. It's my favorite 8-bit microprocessor though :P
<TangentDelta>
The 6800 is way more capable, but nowhere near as cheap as the 6502 was.
<veltas>
6502 is fine if you treat it like a 128-register RISC and don't think too hard about it
<veltas>
What a true 8-bit processor it was
Zarutian_HTC has joined #forth
marksmith has quit [Ping timeout: 240 seconds]
marksmith has joined #forth
boru` has joined #forth
boru has quit [Disconnected by services]
boru` is now known as boru
dave0 has joined #forth
Zarutian_HTC has quit [Remote host closed the connection]
<tabemann_>
back
<tabemann_>
hey guys
<tabemann_>
to me the big problem with the 6502 is that the index registers were 8-bit
<TangentDelta>
Yeah. That's the most annoying thing for me.
<TangentDelta>
It's not too bad with all of the different indirect indexed modes, but it's slower and takes up more code.
marksmith has quit [Ping timeout: 240 seconds]
dave0 has quit [Quit: dave's not here]
sts-q has quit [Ping timeout: 260 seconds]
phadthai has quit [Quit: bbl]
sts-q has joined #forth
phadthai has joined #forth
Gromboli has quit [Quit: Leaving]
gravicappa has joined #forth
<siraben>
today's advent of code was nice
dave0 has joined #forth
dave0 has quit [Quit: dave's not here]
X-Scale` has joined #forth
X-Scale has quit [Ping timeout: 240 seconds]
X-Scale` is now known as X-Scale
Gromboli has joined #forth
marksmith has joined #forth
marksmith has quit [Ping timeout: 265 seconds]
marksmith has joined #forth
marksmith is now known as dlyund
dlyund has quit [Ping timeout: 256 seconds]
marksmith has joined #forth
marksmith has quit [Ping timeout: 246 seconds]
marksmith has joined #forth
lispmacs has quit [Remote host closed the connection]
<veltas>
I am very slowly going through aoc when I have time and feel like it
Vedran has quit [Ping timeout: 260 seconds]
<veltas>
I did spend quite a while trying to optimise my big boy solution for day 1...