A different kind of Walter? :-)

Dan murpsoft at hotmail.com
Fri Apr 20 16:05:02 PDT 2007


Sean Kelly Wrote:

> Dan wrote:
> > Sean Kelly Wrote:
> >> Lionello Lunesu wrote:
> >>> I don't care if there address changes, just as long as there's no data being 
> >>> copied physically. I mean, a block of continuous memory might already be 
> >>> all-over-the-place in physical memory. That's what I want: a VirtualRealloc 
> >>> that returns the address of a new virtual memory block, but which is using 
> >>> the same physical memory.. 'Free' array resizes, surely this is worth 
> >>> something!
> >> Hm, assuming there is nothing else of the page(s) but the data to move, 
> >> it should be possible to do so without explicit copying.  I have no idea 
> >> is VirtualAlloc can do this, but it's definitely possible.
> > 
> > Oh my!
> > 
> > On the x86, this sort of implementation would slaughter your performance, as you'd get massive numbers of cache and page misses.
> > 
> > You could theoretically implement a system on the x86 that would virtualize memory locations arbitrarily, but.... ewww...
> 
> Yeah.  I was thinking that the way to do this would be in the virtual 
> memory manager.  When the pages are moved the page table is updated, etc.
> 
> 
> Sean

That works Sean, if your arrays are only ever split if they're bigger than a page; in which case letting the OS split them and 'handle it' is the best way.  You *can* just declare a 64kb array and it'll handle it well enough.

If you're talking about arbitrarily splitting arrays whenever they happen to collide, and hoping the paging system will handle it, you'll be grabbing 4kb segments for each misplaced segment.  What's almost as bad, is that you'll have to have additional code tracking what segments belong to what virtual array.



More information about the Digitalmars-d mailing list