Skip to content

DRC: Minimise the number of pages that need protection changes#14774

Merged
cuavas merged 1 commit intomamedev:masterfrom
cuavas:rwbase
Jan 9, 2026
Merged

DRC: Minimise the number of pages that need protection changes#14774
cuavas merged 1 commit intomamedev:masterfrom
cuavas:rwbase

Conversation

@cuavas
Copy link
Member

@cuavas cuavas commented Jan 4, 2026

This changes how the misleadingly named "DRC hash table" allocates lookup table blocks. This changes it to allocate larger blocks of memory from the "permanent allocation" area at the end of the cache, rather than allocating smaller "temporary" blocks intermixed with executable code.

This has a number of effects:

  • The lookup tables are no longer marked executable while generated code is running.
  • Nothing needs to write to previously allocated "temporary" cache memory, so at most one page needs to be marked writable when switching to generating code (except in the case of a cache flush, which obviously requires everything to be marked writable).
  • You may be able to get a better idea of the actual amount of generated executable code from cache statistics when the megabytes of lookup tables are separate.

I doubt this will actually have much impact on performance in practice, as even changing protection on a single page requires an expensive page table flush. But I still think it's a cleaner approach to managing memory.

cpu/drcbeut.cpp: Allocate (misnamed) hash table blocks from the
permanent cache area so they aren't intermixed with executable code.

cpu/drccache.cpp: Only mark pages writable starting from the beginning
of unused space.
@cuavas
Copy link
Member Author

cuavas commented Jan 9, 2026

I've seen no objections, and I have other DRC stuff to do that will benefit from having this in place.

@cuavas cuavas merged commit 9aba734 into mamedev:master Jan 9, 2026
7 checks passed
rb6502 pushed a commit that referenced this pull request Jan 9, 2026
cpu/drcbeut.cpp: Allocate (misnamed) hash table blocks from the
permanent cache area so they aren't intermixed with executable code.

cpu/drccache.cpp: Only mark pages writable starting from the beginning
of unused space.
@cuavas cuavas deleted the rwbase branch January 23, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant