A different kind of Walter? :-)
Dan
murpsoft at hotmail.com
Sat Apr 21 10:33:33 PDT 2007
Lionello Lunesu Wrote:
>
> "Dan" <murpsoft at hotmail.com> wrote in message
> news:f0b16i$2k5p$1 at digitalmars.com...
> > 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.
>
> Is a cache using virtual addresses or physical addresses?
The cache loads in _blocks_ of physical memory, which can be specified using a virtual address or a physical address regardless; "virtual memory" just means you're using a translated address.
> > You could theoretically implement a system on the x86 that would
> > virtualize memory locations arbitrarily, but.... ewww...
> >
>
> Isn't this what's happening already?
Not arbitrarily sized ones. If you have a buffer like so:
[slice0,slice1,slice2] = virtual address table
[minemineminemine][7Mb][minemineminemine][24b][minemine] = data buffer
Iterate through your virtual array, and you're going to get a hit on the virtual address table, then on slice0, then on slice1 which will also load the 24b segment and probably slice2 for you.
So you get 3 requests to memory, which if they're not already in the cache, will cause a cache miss. If they're not in memory (swap), they'll cause a page miss.
If you force that memory to stay in one place, it'll all load in 1 shot instead of 3.
If you're curious, a cache miss costs several dozen cycles; while a page miss will cost you thousands.
Additionally, your arbitrary virtual address table takes up alot of space if someone has alot of small dynamic arrays. Worst case, your virtual table can be double the size of the data itself.
Sincerely,
Dan
More information about the Digitalmars-d
mailing list