At 1:13 PM -0700 4/15/99, Mike Pellegrino wrote:
>This reminds me of something when I was working on the virtual memory
>manager. How fast are MemPtrX routines when they have to
>reverse-engineer the handle from the pointer (e.g.,
>MemPtrRecoverHandle)? Is there a direct table lookup going on or is
>there a linear search going on? I tried both ways and I wasn't thrilled
>with my performance given the fact that my lookup tables are in storage
>ram. So I stripped out all VMMPtr routines for the 1.0 release pending
>some algorithmic epiphany which I have not yet had.
MemPtrRecoverHandle is relatively cheap. There's an offset from the chunk
to the master pointer stored in the chunk header, so all
MemPtrRecoverHandle has to do is a little bit of math.
It also does some validation, but that doesn't involve much more than a few
checks of other chunk header flags and making sure the handle also
referenes the chunk.
Most of the time it shouldn't matter much, and you can either keep the
handle around or recover it. It's hard for me to imagine a case where that
would make a critical difference in performance.
--Bob