English Amiga Board


Go Back   English Amiga Board > Requests > request.UAE Wishlist

 
 
Thread Tools
Old 16 November 2023, 15:18   #1
selco
Registered User
 
Join Date: Aug 2013
Location: Germany
Posts: 81
Data cache hit/miss ratio analyser

I found an interesting discussion and eventually understood how the data cache of the 68040/60 is working. (at least I think so ;-) https://stackoverflow.com/questions/...29152#48029152



There are also two gif animations showing which memory of an example program is cached.


Would it be difficult/possible to add some kind of cache analysis to the debugger?


My current idea would be
set a start and end breakpoint
when start reached, enable cache analysis (assume empty cache)
when end breakoint reached, stop cache analysis and read statistics. hits vs. miss ratio could be displayed.



Or is something like that already possible in winuae? Do we have statistics counters already?
selco is offline  
Old 16 November 2023, 19:05   #2
Locutus
Registered User
 
Join Date: Jul 2014
Location: Finland
Posts: 1,181
I think for this to be doable is for the exact cache behavior of the 040 and 060 to be documented, which i'm not sure it is.
Locutus is offline  
Old 17 November 2023, 17:36   #3
selco
Registered User
 
Join Date: Aug 2013
Location: Germany
Posts: 81
The goal would be for instance to find data that are really heavily used and are spread in "critical stride distances" over memory.
selco is offline  
Old 21 November 2023, 10:55   #4
mschulz
Registered User
 
Join Date: Nov 2018
Location: Germany
Posts: 110
Quote:
Originally Posted by Locutus View Post
I think for this to be doable is for the exact cache behavior of the 040 and 060 to be documented, which i'm not sure it is.
The cache behavior is pretty well documented. For example, 68040 Users Manual section 4.1 describes how everything is working including selection of cache line within a set which should be used next. So yeah, such statistics could be eventually implemented. Ofc not in case of real 68040 since it does not do such stats internally.
mschulz is offline  
Old 21 November 2023, 14:54   #5
selco
Registered User
 
Join Date: Aug 2013
Location: Germany
Posts: 81
Quote:
Originally Posted by mschulz View Post
Ofc not in case of real 68040 since it does not do such stats internally.

Sure. Thats why I was thinking the emulator could fill that gap.
selco is offline  
Old 21 November 2023, 18:26   #6
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
Do you mean two counters, cache hits and misses? (separate counters for code and data) that some debugger command would reset/output?

But I am not sure if it returns any useful number(s) because part of test code might be (accidentally) already cached. Should cache counter reset command also (optionally) flush the cache?

Anything more complex would make emulation even more slower.

Cache emulation does what datasheets say but it can't be 100% perfect because order of instruction's internal memory operations are not defined.
Toni Wilen is offline  
Old 23 November 2023, 00:36   #7
selco
Registered User
 
Join Date: Aug 2013
Location: Germany
Posts: 81
Quote:
Originally Posted by Toni Wilen View Post
Do you mean two counters, cache hits and misses? (separate counters for code and data) that some debugger command would reset/output?

Yes. We could run to a breakpoint before a very time consuming loop for instance. Then reset the counters, continue and run to a second breakpoint directly after this loop. Now sow the counters.



Quote:
Originally Posted by Toni Wilen View Post
But I am not sure if it returns any useful number(s) because part of test code might be (accidentally) already cached. Should cache counter reset command also (optionally) flush the cache?

I guess the cache misses at the begin of such a routine are unavoidable/impossible to predict. Bit in a heavily used routine that shouldn't have big impact to the ratio? But yes, flushing the caches seems to be a good idea go give more reproduceable rsults.


Ideally I would like to have some indication if/how I could for instance improve the data cache hit rate by reorganising/shrinking data structures, which code needs to be made smaller or needs to be moved to better fit into the instruction cache lines and wich opcodes cause pipeline stalls...


No idea if that really helps a developer but only WinUAE could provide such insights into the internals.
selco is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with chip ram data cache remz support.WinUAE 11 19 February 2023 13:28
BsdSocket Libray With Data cache emulation Zilog support.WinUAE 2 30 July 2019 20:31
"Data Cache Emulation" configuration not saved(?) oRBIT support.WinUAE 5 30 March 2019 19:01
Is it really hit & miss with CF-IDE adapters? Amiga1992 Hardware mods 17 27 April 2010 22:49
Hit and miss writing ADF's vimfuego support.Other 34 23 September 2009 03:44

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 22:10.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08176 seconds with 13 queries