|
Prolly I do not grok the problem here, but...
What if you only save one single set of text + glyphs? lastText, lastWinGlyphs ... I wouldn't even call that a cache.
I assume we are not talking C++. If we were, the top Goog hit, using std::list + unordered_map , seems fine to me...
And being the Devil's advocate, mewonders, if you might be optimising before you have noticed any performance/resource issue?
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
std::list and unordered map together would whip the heap harder than my current implementation that already crashes the system due to heap fragmentation.
As a rule, it's a terrible idea to use most of the STL on embedded devices. So no "std" containers.
And particularly not a linked list. Jesus.
megaadam wrote: if you might be optimising before you have noticed any performance/resource issue?
7 frames per second without caching
16 with.
If it wasn't for the heap frag forcing me to run the cache in extended memory everything would be fine.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Noted. THX!
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
I think I may have come up with an idea.
My cache has a max_size. I think if I make a private heap of max_size() whenever it is set I may be able to reduce fragmentation. The issue with that is managing removal. Generally when I make a simple memory pool, i allow you to clear it all at once, but not invalidate individual regions. This won't work in this case, because all I'd be doing is moving the fragmentation to the private heap.
What if I could make a compact garbage collector on a private heap though, and just indirect my pointers into it by one more level. (pointer to a pointer so I can change the 2nd pointer after I collect - i got the idea from Boehm's collector - an old GC for C that I would use, but it's a bit heavy handed for just a cache)
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I once saw a linked list implementation where the pointers were inside the data objects. I hated it, at first, but I later realised their point. In your case, only if the number of objects allows for a sequential search, you could preallocate a bunch of something like
struct TextGlyph {
char text[LEN];
Glyph g;
TextGlyph* next;
}
You would never erase anything, just overwrite data and pointers. But I assume you are already well beyond such naïve stuff, even if tend to love naïve. :)
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
I actually am doing something similar.
Here's my structure:
typedef struct {
int accessed;
gfx::size16 dimensions;
uint8_t* data;
} cache_entry_t;
Accessed just supports the LRU. The data is malloc'd and I thought that was causing my problem so I was going to create a simple "vector" to hold all the bytes for every entry, kind of like a private heap, but then I discovered a memory leak.
I fixed the leak, and my problems went away.
I did not expect a leak. I'm usually fastidious about free'ing what I allocate.
In fact, I type free() at the same time as malloc() so I don't forget.
Well, I forgot, apparently.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Alternatively, even more naïve, if your application knows which texts are the most frequent, you could create a permanent store for the most frequently used Text/Glyphs at startup.
"If we don't change direction, we'll end up where we're going"
|
|
|
|
|
honey the codewitch wrote: run the cache in extended memory Oh ye gods. That just triggered a flashback to my MS-DOS programming days. I had an app that ran under the DOS4GW DOS extender (the same as the original DOOM). I had extended memory, expanded memory, real-mode memory, protected memory, protected memory mapping of the real-mode address space...
Software Zen: delete this;
|
|
|
|
|
That's basically the situation.
I have 512KB of primary memory
like 8MB of extended memory.
However, if you want to use more than 4MB of it, you need to page. Remember Himem.sys?
Yeah. That.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
honey the codewitch wrote: Himem.sys Flashback2...
Software Zen: delete this;
|
|
|
|
|
All I want is to include a utilities DLL in a project, and would it let me? No.
I added references to the DLL, I tried producing a new project that targeted .NET 8 rather than .NET 4.8, I added a reference by every means I could think of, I tried adding using statements, I even added the whole sodding utility project to the solution.
Nothing worked, my swear rate rose, and rose, I was on the point of throwing the computer across the room. Or worse, contacting MS Tech support ...
Then I had a brain wave! And added the reference to the DataLayer project instead of the PresentationLayer ... which is where the code that used the utilities was ...
I'm getting too old for this ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have reported issues to Visual Studio support on many occasions and have had good result most though not all of the time.
|
|
|
|
|
Spend most of the day changing .resx files to avoid BinaryFormatter Warning MSB3825 in .NET 8
|
|
|
|
|
A neat thing about embedded is that everything old is new again. I'll explain:
I grew up coding 8 and 16-bit machines. I often had 64KB of RAM, and 1-2MHz of CPU grunt. You had to get creative to do anything with it at all. Embedded is - while not quite as constrained typically (although in some cases, even more constrained), and in any case still pretty limited.
Ergo, old technologies can get a new lease on life because they were designed for systems with relatively anemic hardware.
Enter Windows 3.1 raster font files.
These little monsters are useful to me because there really isn't a common file format for non-antialiased raster fonts.
There are some one-offs, but they're not file formats but rather, in memory, or in flash formats, which is a bit different. While they can be written to a file, the only time you see them in files is C header and implementation files.
.FON files are as good as it gets in that arena, as far as I can tell, so I support them in my embedded graphics library.
Did you know .FONs are essentially renamed .DLLs? In either PE or NE format, and they're stored as an embedded resource. Parsing that is fun!
It's a weird format besides. The pixels are laid out vertically rather than horizontally, for example.
Anyway, this isn't the only time I've rehabilitated old tech for embedded, but it's one of the weirder ones.
I found python code for parsing the font files, which I had to teach myself enough of to port it to C++.
mkwinfont/python/dewinfont.py at master · juanitogan/mkwinfont · GitHub[^]
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
He's the same guy (Simon Tatham) that wrote putty
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Oh wow. I didn't know that!
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
I could see the vertical format working if they are trying to race the raster from the CRT. Remember those?
spit the top row of bits across one line, advance bit mask one position, repeat.
win 1.0 was probably running on slow CPUs when that format was developed. I started with win 2.1 at 12Mhz and EGA was ground breaking. No pre-fetch cache, etc
|
|
|
|
|
It wouldn't work that way because you still have to read the text left to right, top to bottom.
There's probably some reason for it, but I don't know. Curiously, it's the same format as the SSD1306 monochrome OLED display's framebuffer.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
Wordle 1,151 5/6
⬜⬜⬜🟨⬜
⬜🟨⬜⬜🟨
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,151 5/6*
⬜⬜⬜⬜🟨
⬜⬜⬜🟨⬜
⬜🟩⬜⬜🟨
⬜🟩🟨⬜⬜
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,151 4/6*
⬜⬜⬜⬜🟨
⬜🟨⬜🟨⬜
⬜🟩🟨🟨🟨
🟩🟩🟩🟩🟩
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
⬜⬜⬜🟨🟨
⬜🟩🟨🟨🟨
🟩🟩🟩🟩🟩
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
I see you deleted your message...
My 4th guess eliminated one of remaining two words.
Interesting, trying to guess what the masked words could be!
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
|
|
|
|
|
Yes I thought youl'd put a W on the end
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Can't think of a word which has the correct 3 letters of this Wordle, and a W at the end... I must be missing something
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
modified 13-Aug-24 10:06am.
|
|
|
|