dirkwhoffmann / vAmiga

vAmiga is a user-friendly Amiga 500, 1000, 2000 emulator for macOS
https://dirkwhoffmann.github.io/vAmiga
Other
293 stars 24 forks source link

Memory heat maps #827

Open dirkwhoffmann opened 1 month ago

dirkwhoffmann commented 1 month ago

I've just come across this new web port of vAmiga by @coppenheimer, which looks very promising.

One of its standout features is memory heat maps, a feature that could greatly enhance vAmiga's capabilities if supported natively.

There are two main reasons for this project:

  1. Heat maps look cool 😎
  2. At some point, I'd like to add run-ahead to vAmiga as I've implemented it in VirtualC64 5.0, which will be released soon as a beta. A fast cloning logic for virtual machines is a central part of the run-ahead implementation. In the C64 case, I simply copy over memory. In the Amiga case, a smarter memory logic is needed to determine which memory areas are dirty. With some extra effort, this tracking logic should be able to create nice heat maps as a side effect.
mithrendal commented 1 month ago

@dirkwhoffmann coppenheimer is the name of the web port 🤓 the person behind this seems to be @losso3000

losso3000 commented 1 month ago

Wow, that was fast! :) (Thanks to both of you for your stellar emulator and browser work, by the way.)

A little remark: In Coppenheimer, I didn't really implement a heatmap in the traditional sense (or in the way WinUAE does it with the "vh" debugger feature, highlighting the most recent blitter, bitplane, audio and CPU access locations). Assuming you're talking about the smaller memory overview section, I'm just using sparsely sampled memory contents here to crudely map them to different colors. That was easy to do, looked pretty, and even helps to distinguish different data blocks a bit.

dirkwhoffmann commented 1 month ago

or in the way WinUAE does it with the "vh" debugger feature

@losso3000 Before you mentioned it in your post about Coppenheimer, I'd never heard about the heatmap feature in UAE. I cannot try it out since I don't have easy access to Windows machines. Do you know, by chance, if there is a YouTube video showing how it looks in practice? I want to gather some ideas about how a pleasant heatmap could look.

losso3000 commented 1 month ago

Sure: https://heckmeck.de/winuae-vh.mp4 (audio crackling b/c my machine is too slow)

dirkwhoffmann commented 1 month ago

Thanks a lot for the video! Initially, I expected it to look more impressive as the expression "heat map" triggers something like this in me:

Bildschirmfoto 2024-05-26 um 18 50 44

Creating an amazing-looking heat map requires some dynamic glowing effect combined with blurring, I think. With glowing, I mean regions with many accesses steadily increase in brightness and begin to darken when no more accesses happen. This could be done in principle, but a more severe issue is involved. Heat maps are usually two-dimensional, whereas memory is organized in one dimension only. The two concepts only partially fit.

dirkwhoffmann commented 1 month ago

Some preliminary findings:

The 1D/2D issue could be solved by rearranging the address space, e.g., by doing the same as Karnaugh-Veitch diagrams do in Boolean minimization (there, a 1D truth table is mapped to 2D in a way that assures certain neighboring properties). A corresponding mapping can be achieved like this (code is for a 64KB address space):

    for (isize i = 0; i < 65536; i++) {

        isize x = 0, y = 0;
        if (i & (1 << 15)) y += 128;
        if (i & (1 << 14)) x += 128;
        if (i & (1 << 13)) y += 64;
        if (i & (1 << 12)) x += 64;
        if (i & (1 << 11)) y += 32;
        if (i & (1 << 10)) x += 32;
        if (i & (1 << 9)) y += 16;
        if (i & (1 << 8)) x += 16;
        if (i & (1 << 7)) y += 8;
        if (i & (1 << 6)) x += 8;
        if (i & (1 << 5)) y += 4;
        if (i & (1 << 4)) x += 4;
        if (i & (1 << 3)) y += 2;
        if (i & (1 << 2)) x += 2;
        if (i & (1 << 1)) y += 1;
        if (i & (1 << 0)) x += 1;

        // (x,y) is the coordiante of address i in a 256x256 texture

I've already done some experiments with VirtualC64 to see what happens when a heatmap is overlayed on the emulator texture (similar to the DMA debugger approach).

I have to admit, the result looks 🤢

https://github.com/dirkwhoffmann/vAmiga/assets/12561945/a915e1a1-dce9-4282-96c2-68089d21bbf7

Given the unsatisfactory results, I've made the decision to discard the overlay idea. Instead, I will now focus on integrating the heatmap within the memory panel of the inspector. Let's see how it unfolds...

dirkwhoffmann commented 1 month ago

Update: This is how the new prototype implementation looks like in VirtualC64 5.0b1. Looks much better than the texture overlay...

https://github.com/dirkwhoffmann/vAmiga/assets/12561945/7b58a33b-cccb-47be-883d-21f867b2d7a1