POINTER SWIZZLING
TECHNIQUES
1
© Pearson Education Limited 1995, 2005
POINTER SWIZZLING TECHNIQUES
The action of converting object identifiers (OIDs)
to main memory pointers.
• Aim is to optimize access to objects.
• Should be able to locate any referenced objects
on secondary storage using their OIDs.
• Once objects have been read into cache, want to
record that objects are now in memory to prevent
them from being retrieved again.
© Pearson Education Limited 1995, 2005 2
POINTER SWIZZLING TECHNIQUES
• Could hold lookup table that maps OIDs to
memory pointers (e.g. using hashing).
• Pointer swizzling attempts to provide a more
efficient strategy by storing memory pointers in the
place of referenced OIDs, and vice versa when
the object is written back to disk.
© Pearson Education Limited 1995, 2005 3
4
NO SWIZZLING
• Easiest implementation is not to do any swizzling.
• Objects faulted into memory, and handle passed to
application containing object’s OID.
• OID is used every time the object is accessed.
• System must maintain some type of lookup table -
Resident Object Table (ROT) - so that object’s
virtual memory pointer can be located and then
used to access object.
• Inefficient if same objects are accessed
repeatedly.
• Acceptable if objects only accessed once.
© Pearson Education Limited 1995, 2005 5
RESIDENT OBJECT TABLE (ROT)
© Pearson Education Limited 1995, 2005 6
OBJECT REFERENCING
• Need to distinguish between resident and non-
resident objects.
• Most techniques variations of edge marking or
node marking.
• Edge marking marks every object pointer with a
tag bit:
• if bit set, reference is to memory pointer;
• else, still pointing to OID and needs to be
swizzled when object it refers to is faulted into.
© Pearson Education Limited 1995, 2005 7
OBJECT REFERENCING
• Node marking requires that all object references
are immediately converted to virtual memory
pointers when object is faulted into memory.
• First approach is software-based technique but
second can be implemented using software or
hardware-based techniques.
© Pearson Education Limited 1995, 2005 8
HARDWARE-BASED SCHEMES
• Use virtual memory access protection violations
to detect accesses of non-resident objects.
• Use standard virtual memory hardware to trigger
transfer of persistent data from disk to memory.
• Once page has been faulted in, objects are
accessed via normal virtual memory pointers and
no further object residency checking is required.
• Avoids overhead of residency checks incurred by
software approaches.
© Pearson Education Limited 1995, 2005 9
POINTER SWIZZLING - OTHER ISSUES
• Three other issues that affect swizzling techniques:
• Copy versus In-Place Swizzling.
• Eager versus Lazy Swizzling.
• Direct versus Indirect Swizzling.
© Pearson Education Limited 1995, 2005 10
COPY VERSUS IN-PLACE SWIZZLING
• When faulting objects in, data can either be
copied into application’s local object cache or
accessed in-place within object manager’s
database cache .
• Copy swizzling may be more efficient as, in the
worst case, only modified objects have to be
swizzled back to their OIDs.
• In-place may have to unswizzle entire page of
objects if one object on page is modified.
© Pearson Education Limited 1995, 2005 11
EAGER VERSUS LAZY SWIZZLING
• Moss defines eager swizzling as swizzling all OIDs
for persistent objects on all data pages used by
application, before any object can be accessed.
• More relaxed definition restricts swizzling to all
persistent OIDs within object the application wishes
to access.
• Lazy swizzling only swizzles pointers as they are
accessed or discovered.
© Pearson Education Limited 1995, 2005 12
DIRECT VERSUS INDIRECT SWIZZLING
• Only an issue when swizzled pointer can refer to
object that is no longer in virtual memory.
• With direct swizzling, virtual memory pointer of
referenced object is placed directly in swizzled
pointer.
• With indirect swizzling, virtual memory pointer is
placed in an intermediate object, which acts as a
placeholder for the actual object.
• Allows objects to be uncached without requiring swizzled
pointers to be unswizzled.
© Pearson Education Limited 1995, 2005 13