druntime's PAGESIZE

Jacob Carlborg doob at me.com
Sun Nov 1 13:09:48 UTC 2020

On 2020-10-31 20:06, Denis Feklushkin wrote:

> Looks like some of these values are redundant:
> src/rt/lifetime.d
> 31:        PAGESIZE = 4096,
> src/gc/pooltable.d
> 181:    enum PAGESIZE = 4096;
> src/gc/impl/conservative/gc.d
> 1133:{   PAGESIZE =    4096,
> This is correct? Which ones are related to each other? Which ones can be 
> freely changed so that nothing (silently) breaks?

These are not correct. When I ported D to iOS I had to deal with this. 
The page size on iOS (and derived platforms) is 16K. It did change it in 
a few places where it broke the unit tests (or otherwise failed). I 
added two new symbols to `pageSize` and `minimumPageSize` [1]. The 
difference is that `minimumPageSize` is a compile time known value and 
might not be correct. `pageSize` is a runtime value which is initialized 
early in the startup phase. It's always correct since it gets the page 
size from the OS. `minimumPageSize` is discouraged, we might remove it.

I did a search through druntime and Phobos for the value `4096` and it 
appears quite a lot. I don't know how many of these values have to match 
the page size (i.e. for correctness) how many of these should ideally 
match the page size (i.e. for performance) or how many of these refer to 
something else (or it won't matter for performance or correctness).

I fixed all the places that was required to get the unit tests in 
druntime and Phobos to pass. If that means we're all good (at least for 
correctness) or that we don't have enough unit test coverage, I don't know.


/Jacob Carlborg

More information about the Digitalmars-d mailing list