Sorry, but that's wrong. The _reason_ paging was developed in the first place was to avoid those large blocks, the resulting fragmentation, and the garbage-collection necessary to maintain free space in a large block. This idea takes us back 40 years into the past before the virtual machines of the 60's were developed.hgm wrote:Well, the eval I have in mind doesn't really use much memory at all. 32KB is huge. Adding a few Piece-Square Tables for each piece type (16 x 64 bytes = 1KB) would not kill me. But playing a match without them will just tell you next to nothing.
About paging:
When you allocate a small object, you are a mere user, and it will be allocated within your user address space with whatever granularity you like. When your total demand on memory exceeds a 256KB boundary through the allocation, the OS will just allocate a new 256KB chunk to you, which will be able to satisfy your demand for small objects for a long time.
The idea that allocating in 256KB chunks would 'waste' memory is seriously flawed thinking. Trying to prevent this 'wastage' by packing the used fraction densely and collecting all the unused memory into one contiguous block would still leave the memory unused, and thus just as wasted. That you _could_ run other programs in that space is worth zilch if you don't have other tasks that _want_ to run. You are just trying to 'save' memory in order to leave it idle...
There are places where big blocks are nice, and with today's hardware, one can choose 4K or 4M (sometimes 2M depending on machine) page sizes. Big pages make the TLB far more effective, and also reduces overhead for when a program grows big, but by having to grab a bunch of small pages.
But _most_ programs are not that big, and forcing 256K granularity is simply a mistake that has been corrected for many years.
There are lots of other issues. I want data memory, that is read/write accessable, so you have to give me 256K. I need 4K. I want read-only memory for constants. You have to give me 256K, but I only want 4k. I want execute-only memory for the code. same story. When I do a page replacement, I am forced to write out the entire chunk, and read in the entire chunk, since that is the only way I can use that memory for someone else. Even though there is only one page I need/want.
If I look in my task manager, it turns out that almost any task uses about 2MB of memory, and there are only 5 (of 32) that use less than 1MB (the smallest using 168KB). It doesn't seem a significant fraction of memory would be wasted by rounding everything up to 256KB multiples.
It would _not_ be efficient. More accurately, it would be impossibly slow.
optimal page size has _nothing_ to do with the disk drive size/speed. Nothing at al. Anything you can do with large page sizes, I can do with small page sizes. Optimal page size has to do with the way protection is done, and the way most programs grow, both large and small ones. Most programs have at least two types of pages, execute and read/write. I don't want to allocate and release 512K just to display today's date...
We don't have 4KB pages for nothing? Are you claiming that the optimal page size is independent of total memory size and hard-disk I/O characteristics? That a page size that is optimal for a 4MB memory is also optimal for a 4GB memory? And that you would like to swap in equal chunks to a disk of 40MB as to a disk of 320GB? This seems rather unlikely, and I don't believe it for a minute!
There are other significant issues with shared memory (such as shared libraries, shared executable pages, etc...
Believe me, this has not been developed in an ad hoc way over the past 30 years, it has been studied, simulated and measured to death, to get us to where we are today.