<<

Charles Lamb Gordon Landis Jack Orenstein Dan Weinreb

SO October 1991/%1.34, No.10/COMMUNICATIONS OF THE ACM bjectStore is an object-oriented management system (OODBMS) that provides a tightly integrated language interface to the traditional DBMS features of persistent storage, transaction management (concurrency control and recovery), distributed data access, and associative queries. ObjectStore was designed to provide a unified programmatic interface to both persistently allocated data (i.e., data that lives beyond the execution of an applica- tion program) and transiently allocated data (i.e., data that does not survive beyond an application's execution), with object-access speed for persistent data usually equal to that of an in-memory dereference of a pointer to transient data.~-_- ...... - ...... - ...... - ...... -

These goals were derived from tain pointers, use C++ virtual to write code that translates be- the requirements of ObjectStore's functions and , tween the disk-resident representa- target applications, which are typi- etc). In particular, there is no need tion of data, and the representation cally data-intensive programs that to inherit from a special "persistent used during execution. For exam- perform complex manipulations on object" base class. Different objects ple, to store a C+ + object into a re- large of objects with intri- of the same type may be persistent lational database, the programmer cate structure, e.g., CAD, CAE, or transient within the same pro- must construct a mapping between CAP, CASE, and geographic infor- gram. the two, and write code that picks mation systems (GIS). This struc- There are several motivations for fields out of tuples and copies them tural complexity is generally real- our goal of making ObjectStore into data members of objects. (This ized by inter-object references, e.g., closely integrated with the pro- is part of the problem that has been pointers from one object to an- gramming language. These in- called the "impedance mismatch" other. Objects are located, possibly clude: between a with the intent to update them, by and a database access language [2, traversing these references and by Ease of learning: It was intention- 13].) With ObjectStore, no translat- associative queries. ally designed so that a C+ + user ing and no copying is needed. Per- We selected C + + as the primary would only have to learn a little sistent data is just like ordinary language through which Ob- more in order to try out Ob- heap-allocated (transient) data: jectStore is accessed because it is jectStore and start to use it effec- once a pointer is obtained to it, the becoming a very popular language tively. After that, a user can learn user can just use it in the ordinary among the developers of Ob- more, and take advantage of more way. ObjectStore automatically jectStore's target applications. Ob- of the capabilities the database of- takes care of locking, and keeps jectStore can also be used from C fers. In particular, there is no need track of what has been modified. programs--providing access from to learn a new or a new C is easy because the data model of way to define objects. The declara- Expressive power: We wanted the C is a subset of that of C+ +. Use of tive and procedural parts of the interface to persistently allocated ObjectStore from other program- language are used for both kinds of objects to support all of the power ming languages is discussed later. objects. By providing a gradual of the host programming language. The key to ObjectStore's integra- learning path and making it easy This contrasts with the traditional tion with C+ + is that persistence is for users to get started, we hope to data manipulation capabilities of not part of the type of an object. make ObjectStore accessible to a languages such as SQL, which are Objects of any C++ data type wider range of developers, and much less powerful than a general- whatsoever can be allocated tran- help ease the transition into the use purpose programming language. siently (on the ordinary heap) or of object-oriented database tech- persistently (in a database), from nology. Reusability: We wanted to promote built-in types such as integers and reusability of code, by allowing the character strings, to arbitrary user- No translation code: We wanted to same code to operate on either per- defined structures (which may con- save the programmer from having sistent or transient data, and to

COMMUNICATIONSOF THE ACM/October 1991/Vol.34, No.10 Sl allow libraries that were developed mance, the target applications are make the speed of dereferencing of for manipulating transient data to very different from traditional pointers to persistent objects be as work on persistent data without database applications such as pay- close as possible to that of transient change. For example, if a program- roll programs and on-line transac- objects, namely the speed of a sin- mer has a library routine that takes tion processing systems, in several gle load instruction. an array of floating-point numbers ways, as we found from interview- ObjectStore also has some of the and computes the fast Fourier ing developers of such applications. same performance goals as ordi- transforra, he or she can pass it an nary relational DBMSs, and it gen- Temporal locality: When many ObjectStore persistent array, and it erally accomplishes these using will work. Usually, if a library does users access a shared database, very familiar techniques such as indexes, often the next user of a data item not need to do any persistent allo- query optimization, log-based re- cation of its own, the library can be will be the same as the previous covery, and so on. The implemen- applied to persistent data without user. In other words, while concur- tation section explains how we ap- even being recompiled. rent access must be allowed and proached all of these performance must work correctly, many data goals, focusing on the aspects of Conversion: Many programmers items will be used 'mostly' by one ObjectStore that differ from con- who are interested in using object- user over a short span of time. ventional techniques. oriented DBMSs would like to add Spatial locality: Often an applica- Another goal of ObjectStore is to persistence to existing applications tion will use only a portion of a provide several features that are that deal with transient objects, database, and that portion will be missing from C++ and from most rather than build new applications (or can be arranged to be) in a small DBMSs: a collection facility (sets, from scratch. We wanted to make it section of the database that is con- lists, and so on), a way to express as easy as possible to convert an ex- tiguous, or mostly so. bidirectional relationships, and isting application to use persistent support for groupware based on objects throughout. In particular, Fine interleaving: Applications versioned data. this means that basic data opera- often interleave small database op- tions such as dereferencing point- erations (i.e., go from one object to Application Interface ers and getting and setting data a reference object) with small In addition to the data definition members should be syntactically the amounts of computation. That is, and manipulation facilities pro- same for persistent and transient there are many very small database vided by the host languages, C and objects, and that variables should operations rather than relatively C++, ObjectStore provides sup- not have 1:o have their type declara- few large ones. If every database port for accessing persistent data tions changed when persistent ob- operation required a significant inside transactions, a library of col- jects are used. per-operation overhead cost (such lection types, bidirectional relation- as the cost of sending a network ships, an optimizing query facility, Type checking: We wanted the message), overhead costs would and a version facility to support col- compile-time type-checking of become prohibitive. laborative work. Tools supporting C+ + to apply to persistent data as Developers told us that it is im- database schema design, database well as transient data, with the en- perative that ordinary data manip- browsing, database administration, tire application using a single type ulation be as fast as possible. For and application compilation and system. The 's type check- example, an ECAD circuit simula- debugging, are also provided. ing applies to objects in the data- tion is CPU-intensive, traversing a There are three programming base. For example, a variable refer- network of objects representing a interfaces supported, a C library ring to an object of class employee circuit, carrying out computations interface, a C++ library interface, would have type 'employee *'. Such on the way. These simulations are and an extended C+ + which pro- a variable could refer to a persistent quite expensive. Any approach to vides a tighter language integration employee or a transient employee, data management that penalizes to the query and relationship facili- at different times during program the running time of such an appli- ties. This interface is accessible only execution. A function that takes a cation is impractical. This means through ObjectStore's C++ com- reference to an employee as an ar- that one critical operation must be piler, while the two library inter- gument can therefore operate on a as fast as possible: the operation of faces are accessible through other persistent or a transient employee. obtaining data from an object, third-party C or C++ , The second goal of ObjectStore given a pointer or reference to the thus providing maximum portabil- is to provide a very high perfor- object. This operation might be ity. All of the features and perfor- mance for the kinds of applications called 'fetching an object'; more mance benefits of the ObjectStore to which ObjectStore is targetted. precisely, it is dereferencing a architecture are realized in all of From the point of view of perfor- pointer. ObjectStore is designed to the interfaces.

S2 October 1991/Vo1.34, No.10/COMMUNICATION8OF THE ACM Accessing Persistent Data :ili~!:!iii!i i:!!:iiiiiii: A simple C+ + program which uses :ili!!i!i!i!! #Lrxcludo (obJ ectstore/obj ect~tore H~! the extended C+ + interface to the iiiii;ii!!~ #include (r~Co~ds H) system is presented in Figure 1. iiiii~ill ~iiiiii This program opens an existing database, creates a new persistent { object of class employee, adds the new employee to an existing de- //De~e a e, ~" olnt" into ~e partment, and sets the salary of the // He of ~e "~o ~.dep nt" employee to 1,000. The keyword persistent specifies a storage class, d~.~b~e *db; saying that this variable resides in perst~nt(db) ~department* englnee dep nt; the specified database. Persistent variables associate names with per- //Open ~e ch~t~b~e. sistent objects, providing the start- db ~ ~e::~ ("/co~ ecords"); ing point from which navigations or queries begin. The db argument to //Start a ~aot~on so ~at t~e dat,abaso the new operator specifies that the /loan be ~ssed. employee object being created ta'~aotton::be~(); should be allocated in database db. It should be noted that the ma- //The next ~ee s~atements crea~ and m a nipulation of data looks just like an //persistent obJeog represent!rig a person named Fred, ordinary C++ program, even loyeo .emp ~ (~b) empl0yoe ("~d"); though the objects are persistent, e > loyoo (emp); They also compile into the same omp~>sal~= 1~0; machine instructions: the update of the salary field just uses a simple //CO ~; all oh~eS ~ ~ ~e. store instruction. ObjectStore auto- ~t,lon::c ~); matically sets read and write locks, } and automatically keeps track of what has been modified, helping to protect the integrity of the database against the possibility of program- Manipulating persistent data mer error. Access to persistent data is guaranteed to be transaction- consistent (i.e., all-or-none update /* file records.H */ ij jli/i semantics), and recoverable in the event of system failure. class employee It should be noted that in Fig- { ure 1 the variable engineering_ public: department is not explicitly initial- char* ilaIne; ized. This is because it is a persis- int salary; tent variable, which refers to an }; object stored in the "/compax~/ class department recorch~" database. The object is { looked up by name, 'en- public: gineering_department', in the data- os_Set(employee*> employees, base, and the program variable is initialized to refer to the named void add_employee (employee *e) object in the database. (It would { employees->insert (e); } have been an error if there had been no such object in the data- int works_here (employee *e) base.) The persistent keyword in { return employees-->contains (e); } !ii!!iiii!!iiiiii!i!i!iili!iii!iiiiiiiii iiii!!i!i iiiiiiiii ii i!!i the ObjectStore extended C+ + in- iii!iii~ili~iiiiiiiii!~iiii!iiiiiiiiiiiiiiiii!!i!iii!iiii~i!i!iii!~i!~ ferface simply provides a short- hand for looking up an object in the database by name, and binding a Using COlleCtions

COMMUNICATIONS;OF THE ~M/October 1991/Vol.34, No.10 S~ local program variable to the per- tures, such as lists, with more effi- developer's involvement from cod- sistent database object. cient but more complex structures ing data structures to describing such as b-trees or hash tables. This access patterns. Collections aspect of application development Figure 2 shows the user-written ObjectStore provides a collection is also handled by the collection li- include file re0ords.H, used in this facility in 1:he form of an object class brary. Users may optionally de- example. Note that the class de- library. Collections are abstract scribe intended usage by estimating partment declares a data member structures which resemble arrays in frequencies of various operations, of type os_Set(employee*) .os_Set traditional programming lan- (e.g., iteration, insertion, and re- is a (parameterized) collection class, guages, or tables in relational moval), and the collection library found in the ObjectStore collection DBMSs. Unlike arrays or tables, will transparently select an appro- class library. If d is a department, however, ObjectStore collections priate representation. Further- then d->add_.employee(e) simply provide a variety of behaviors, in- more, a policy can be associated with adds e into d's set of employees. cluding ordered collections (lists), the collection, dictating how the d-->worlm_here(e) returns true if and collections with or without representation should change in e is contained in d's set of employ- duplicates (bags or sets). response to changes in the collec- ees, false otherwise. Performance tuning often in- tion's cardinality. These perfor- ObjectStore includes a looping volves replacing simple data struc- mance-tuning facilities reduce the construct to iterate over sets. For example, the code in Figure 3 gives ...... a 10% raise to each employee in department d. In the loop, e is bound to each element of d->em- ploy0es in turn.

The Relationship Facility Complex objects such as parts hier- archies, designs, documents, and Iteration over a collection multimedia information can be modeled using ObjectStore's rela- tionship facility. Relationships can /* file records.H ,/ be thought of as a pair of inverse pointers, so that if one object points class employee to another, the second object has an ( inverse pointer back to the first. pub]to: Relationships maintain the integrity skring name; of these pointers. For example, if ~t salary; one participant in a relationship is dep~ent* dept deleted, then the pointer to that tnve~le_member d~m-~lanent: :em91oyeee; object, from the other participant, is set to null. One-to-one, one-to- many, and many-to-many relation- class department ships are supported. To continue the example in Fig- publlc- ure 3, we could create a relation- os~et(employee*) employees ship between employees and de- Lnve~e_membex. eml)loyeetzde]pt; partments, as in Figure 4. The dept data member of employee and the void azid_.employ0e (employee *e) employees data member of de- ( employoos-->tnsex~ (e); } pa-m,m0nt are declared to be in- verses of one another. Because one void works_here (employee *e) data member is a single pointer and { employees-->contalns (e) ; } the other is a set, the relationship is }; one-to-many. Whenever an em- ployee is inserted into a depart- ment's set of employees, the em- ployee is automatically updated to Using relationships refer to the department (and vice-

S4 October 1991/Vol.34, No.IO/COMMUNIC&TIONS OF THE ACM versa). Similarly, when an employee pressions or queries. Continuing os_Set(employee*)> is deleted from a department's set the previous example, suppose that & work_with__fred = of employees, the pointer from the ~]1 employees is a set of employee alLemployees-->query( employee to the department is set objects: 'employee*', to null, guaranteeing referential "dept-- >employees os_Set(employee*) all_employees; integrity. [: name == \'Fred'\ :]"); Syntactically, relationships are The first argument to query, accessed just like data members in The following statement uses a employee*, indicates the type of query against alLemployees to C++, but updating the value of a the collection elements. The second find employees earning over relationship causes the inverse rela- argument is simply the string rep- tionship to be updated as well, so $100,000, and assign the result to resenting the query expression. It is that the two sides are always consis- overpaid_employees: also possible to use the library inter- tent with one another. This means os_Set(employee*)& face to store precompiled and opti- that after d-->add_employee(e) in overpaid_employees = mized queries in the database for the code example given in Figure 1, alLemployees later execution. o's dept would be engineering_ [: salary >= 100,000 :]; In its current form, the Ob- department, even though this field jectStore query language can ex- [: :] is ObjectStore syntax for was not explicitly set by the appli- press 'semijoins' but not full joins; queries. The contained expression cation. This update of e would oc- i.e., the result of a query is a subset is a selection predicate, that is (con- cur as a result of inserting e into of the collection being queried. d-->employees, because of the in- ceptually) applied to each element verso_member declarations. Simi- of A.11 employees in turn. (In fact, larly, if o-->dept is set to another the query will be optimized if an Versions department, d2, then e is removed index on salary is present. This is ObjectStore provides facilities for from d-->employees, and inserted discussed later.) multiple users to share data in a to d2-->employees. In general, Any collection, even one result- cooperative fashion (sometimes re- maintenance actions can involve ing from an expression, can be que- ferred to as groupware). With these simply unsetting the inverse, or ac- ried. For example, this query finds facilities, a user can check out a ver- tually deleting the object on the in- overpaid employees of department sion of an object or group of ob- verse, at the schema-definer's dis- d: jects, make changes (perhaps en- cretion. The latter behavior is tailing a long series of individual d-->employees useful for deleting hierarchies of update transactions), and then [: salary >= 100000 :] objects, so that, for example, delet- check changes back in to the main ing an assembly would cause all of Query expressions can also be development project so that they its subassemblies to be deleted, nested, to form more complex que- are visible to other members of the along with their subassemblies, re- ries. The following query locates cooperating team. In the interim, cursively. employees who work in the same other users can continue to use the department as Fred: previous versions, and therefore Associative Ouerles are not impeded by concurrency all_employees In relational DBMSs, queries are conflicts on their shared data, re- [: dept-->employees expressed in a special language, gardless of the duration of the edit- [: name = = 'Fred' : ] : ]; usually SQL. SQL has its own vari- ing sessions involved. These ex- ables and expressions, which differ Each member of all employees has tended editing sessions on private, in syntax and semantics from the a department, dept, which has an checked-out versions are often re- variables and expressions in the embedded set of employees. The ferred to as long transactions. The host language. Bindings between nested query is true for depart- design was influenced by [3, 6, 9, variables in the two languages must ments having at least one employee ]0]. be established explicitly. Ob- whose name is Fred. If other users want to make con- jectStore queries are more closely All of these examples make use current parallel changes, they can integrated with the host language. of the language extensions available check out alternative versions of the A query is simply an expression only through the ObjectStore C+ + same object or groups of objects, that operates on one or more col- compiler; the [: :] syntax, for exam- and work on their versions in pri- lections and produces a collection ple, is a language extension. The vate. Again, the result is that there or a reference to an object. same queries can be expressed via are no concurrency conflicts, even Selection predicates, which ap- the library interface. The previous though the users are operating on pear within query expressions, are query would be restated in the (different versions of) the same also expressions, either C++ ex- C+ + library interface as: objects. Alternative versions can

COMMUNICATIONS OF THE ACM/October 1991/Vol.34, No.10 S S later be merged back together to of type. This means that instances ing as fast as possible. This means reconcile differences resulting of any type may be versioned, and that ordinary pointers from the from this parallel development. that versioned and nonversioned host language must be able to serve This merging operation is a diffi- instances can be operated on by the as references from one persistent cult prob]Lem and is left to the user same user code. This makes it easy object to another. to implement on an application- to take an existing piece of code, ObjectStore's performance goals specific basis [8]. In support of this, which has no notion ofversioning-- demand that once the target object ObjectStore allows simultaneous for example, a circuit-design simu- has been retrieved from the data- access to both versions of an object lator-and use it on versioned data. base, subsequent references should during the merge. The simulator does not have to be be just as fast as dereferencing an Users can control exactly which rewritten, because operating on a ordinary pointer in the language. versions I:o use, for each object or particular version of a circuit de- This means that dereferencing a group of objects of interest, by set- sign is identical to operating on a pointer to a persistent target must ting up private workspaces that nonversioned design. compile exactly the same as specify the desired version. This Programs using versioned data dereferencing a pointer to a tran- might be the most recent version, need not distinguish among sient target, (i.e., as a single 'load' or a particular previous version versioned, persistent, and transient instruction), without any extra in- (such as the previous release), or data in accordance with Ob- structions to check whether the tar- even a version on an alternative jectStore's design principles. get object has been retrieved from branch. Users can also use the database yet. This creates a di- workspaces to selectively share their Architecture and lemma, since it is possible that the work in progress. Workspaces can Implementation target object really has not yet been inherit fi'om other workspaces, so retrieved from the database. that one designer could specify that Storage System and Memory- Fortunately, these design goals his or her workspace should by de- Mapped Architecture are analogous to those of virtual fault inherit "whatever is in the One fundamental operation of a memory systems, which support team's shared workspace"; he or database programming language is uniform memory references to she could, then add individual new dereferencing: finding and using a data, whether that data is located in versions as changes are made, over- target object that is referred to by a primary or secondary memory. riding thiis default. source object. ObjectStore's inter- ObjectStore takes advantage of the For example, a team of designers face goals state that this must work CPU's hardware, working on a CPU design might set just as in ordinary C+ +, to provide and the 's inter- up a workspace in which all of their transparent integration with the faces that allow ordinary new versions are created. Only language and to make dereferenc- to utilize that hardware. The virtual when their CPU design is com- pleted would the finished version(s) be checked in to the corporate workspace, making them available to, say, the manufacturing group. I CORP 1 Within the design team's work- space, there might be multiple subworkspaces, which are used by c.u ) f -,.° l subgroups of the design team or individual team members. Just as the entire group makes its work available to manufacturing by ,,u ) [ o,c. ) checking in a completed version to the corporate workspace, individ- ual designers or teams of designers can make their work-in-progress available to one another by check- ing their intermediate versions in to l Team 2 J their shared workspaces. This is il- lustrated in Figure 5. Just as the persistence of an ob- ject is independent of type, the ver- sioning oJF an object is independent Nesting of workspaces

S6 October 1991/Vo1.34, No.IO/COMMUNICATION$OFTHE ACM memory system allows ObjectStore from the client, and stores them on seen by the language in virtual to set the protection for any page of disk. The is also responsible memory. This avoids potential per- virtual memory to no access, read for concurrency control and recov- object overhead such as calling a only, or read/write. When an Ob- ery, using techniques similar to dynamic memory allocator, creat- jectStore application dereferences a those used in conventional DBMSs. ing entries in object tables, or refor- pointer whose target has not been It provides two-phase locking with matting the nonpointer elements of retrieved into the client (i.e., a page a read/write lock for each page. the object. set to no access), the hardware de- Recovery is based on a log, using When a transaction finishes, all tects an access violation, and the the write-ahead log protocol. pages are removed from the ad- operating system reflects this back Transactions involving more than dress space and modified pages are to ObjectStore, as a memory fault. one server are coordinated using written back to the server (the client ObjectStore retrieves the page from the two-phase commit protocol. waits for an acknowledgment from the server and places it in the cli- The server also provides backup to the server that the pages have been ent's cache. It then calls the operat- long-term storage media such as safely written to disk). However, ing system to set the protection of tapes, allowing full dumps as well as the pages remain in the client the page to allow accesses to suc- continuous archive logging. cache, so that if the next transaction ceed (i.e., read only). Finally, it re- Since the server has no knowl- uses those pages, it will not have to turns from the memory fault, edge of the contents of the page, communicate with the server to re- which causes the dereference to much of the query and DBMS pro- trieve them; they will already be restart. This time, it succeeds. Sub- cessing is done on the client side of present in the cache. This improves sequent reads to the same target the network. This contrasts with performance when several succes- object, or to other addresses on the traditional relational DBMS sys- sive transactions use many of the same page, will run in a single in- tems in which the server is largely same pages. Typical ObjectStore struction, without causing a fault. responsible for handling all query applications interleave computation Writes to the target page will result processing, optimization, and for- very tightly with database access, in faults that cause the page access matting. Although such offioading doing some computation, then mode and lock to be upgraded to of work from the server is not ideal dereferencing a pointer and read- read-write. All virtual memory for all applications, this architec- ing or changing a few values, then mapping and manip- ture does not preclude having the doing some more computation, etc. ulation in the application is handled server handle more of the work. If it were necessary to communicate by the operating system under the ObjectStore maintains a client with a remote server for each of direction of ObjectStore, using nor- cache, a pool of database pages that these simple database operations, mal system calls. have recently been used, in the vir- the cost of the network and sched- The ObjectStore server provides tual memory of the client host. uler overhead would be enormous. the long-term repository for persis- When the application signals a By making the data directly avail- tent data. Databases can be stored memory fault, ObjectStore deter- able to the application and allowing either of two ways: within files pro- mines whether the page being ac- ordinary instructions to manipulate vided by the operating system's file cessed is in the client cache. If not, the data, such applications perform system, or within partitions of disks, it asks the ObjectStore server to faster. using ObjectStore's own file system. transmit the page to the client, and Since a page can reside in the cli- The latter provides higher perfor- puts the page into the client cache. ent cache without being locked, mance, by keeping databases as Then, the page of the client cache is some other client might modify the contiguous as possible even as they mapped into virtual address space, page, invalidating the cached copy. gradually grow, and by avoiding so that the application can access it. The mechanism for making sure various operating system over- Finally, the faulting instruction is that transactions always see valid heads. The server and the client restarted, and the application con- copies of pages is called 'cache co- communicate via tinues. herence'. A copy of a page in a cli- when they are running on different Many applications tend to refer- ent cache is marked either as shared hosts, and by faster facilities such as ence large numbers of small ob- or exclusive mode. The server keeps shared memory, and local sockets jects, but networks are, in general, track of which pages are in the when they are running on the same more efficient for bulk data. To caches of which clients, and with host. compensate for this, whole pages of which modes. When a client re- The server stores and retrieves data are brought from the server to quests a page from the server and pages of data in response to re- the client and placed in the cache the server notices that the page is in quests from clients. The server has and mapped into virtual memory. the cache of some other client (the no knowledge of the contents of a Objects are stored on the server in holding client), the server will check page. It simply passes pages to and the same format in which they are to see if the modes conflict. If they

COMMUNICATIONSOF THE ACM/October 1991/Vo1.34, No.10 S7 Applications can improve pe!rforman¢e by exercising control over the placement of ObjeCtS within a database.

do, the ,~erver sends a message to the application. It maintains a vir- size of the available address space, the holding client, asking it to re- tual address map that shows which relocation is required. move the page from its cache. This database and which object within ObjectStore maintains an auxil- is called a callback message, since it the database is represented by any iary data structure called the tag goes in t]~e opposite direction from address. As the application refer- table that keeps track of the loca- the usual request: the server is ences more databases and more tion and type of every object in the making a request of the client. objects, additional address space is database. When a page is mapped When the holding client receives assigned, and the new objects are into virtual address space and the callback, it checks to see if the mapped into these new addresses. pointer relocation is needed, Ob- page is locked, and if not, agrees to At the end of each transaction the jectStore consults the tag table to immediately relinquish the page, virtual address map is reset, and find out what objects reside on the and removes the copy of the page when the next transaction starts, page, and then uses the database from its cache. If the page is locked, new assignments are made. schema to learn which locations the client replies negatively to the This solution does not place any within each object contain pointers. server, and the server forces the limits on the size of a database. Nat- It then adjusts the value of the requesting client to wait until the urally, each transaction is limited to pointer to account for the new as- holder is, finished with the transac- accessing no more data than can fit signments of data to the virtual tion. When the holding client com- into the virtual address space. In address space. To minimize space mits or aborts, it then removes the practice, this limit is rarely reached, overhead while keeping access fast, copy of the page from its cache, and since modern have very the tag table is heavily compressed, the server can allow the original cli- large virtual address spaces, and and is indexed. Each tag table entry ent to proceed. The use of callback transactions are generally short contains a 16-bit type code, which messages was inspired by the An- enough that they do not access indexes into a type table stored in drew File System [11]. Related nearly as much data as can fit. An the database's schema. The type cache coherency algorithms are dis- operation large enough to ap- table entry indicates which words of cussed in [4]. proach this limit would be divided the type contain pointers. Tag table In an ideal architec- into several transactions, and pages are brought into the client ture with unlimited virtual address checked out into a workspace to cache as needed, and managed in space, every object in every data- provide isolation from other users. the cache like ordinary database base could have a unique address, When a page is mapped into vir- pages. and virtual addresses could serve as tual memory, the correspondence Applications can improve per- unchanging object identifiers. of objects and virtual addresses may formance by exercising control Modern computers have virtual have changed. The value of each over the placement of objects address spaces that are very large, pointer stored in the page must be within a database. By clustering but not unlimited. Single databases updated, to follow the new virtual together objects that are frequently can exceed the size of the virtual address of the object. This is called referenced together, locality is in- address space. Also, two indepen- relocation of the pointers. When creased, the client cache is used dent databases might each use the possible, ObjectStore arranges to more efficiently, and fewer pages same address for their own objects. assign the address space so that need to be transferred in order to This is 1Lhe fundamental problem pointers as stored on the server access the objects. ObjectStore di- that must be solved by any virtual happen to be the same as the values vides a database into areas called memory.-mapping approach to a they ought to have in virtual mem- segments, and whenever an appli- DBMS. ory. In this case, relocation is not cation creates a new persistent ob- ObjectStore solves this problem needed, which improves perfor- ject, it can specify the segment in by dynamically assigning portions mance. But sometimes relocation which that object should be created. of address space to correspond to cannot be avoided. For example, Applications can create as many portions of the databases used by when the database size exceeds the segments as are needed. Segments

S8 October 1991/Vol.34, No.10/COMMUNICATIONS OF THE ACM Since locking granularity is on a per-page basis, the advantages of clustering are realized in decreased locking overhead.

may be transferred from server to ties that ObjectStore needs. Ob- tions _an be obtained by specifying client either en masse, or one page jectStore is also available on Micro- combinations of behavior for an at a time, depending on the setting soft Windows 3.0. Windows does os_collection, (e.g., a list without of an application-controlled per- not have a protected kernel like duplicates, or a set that raises an segment flag. Unix, so ObjectStore controls vir- exception upon insertion of a du- Objects can cross page bounda- tual memory directly. plicate, instead of silently ignoring ries, and can be much larger than a it). page. Image data, for example, can Collections The other hierarchy under os_ be stored in very large arrays that In designing the collection facility, collection provides for various rep- span many pages. If an application an important design goal was that resentations of collections. Each needs to access only a small portion performance must be comparable representation supports the entire of such a huge object, it can use to that of hand-coded data struc- os_collection interface, but with dif- page-granularity transfer, to trans- tures, across a wide range of appli- ferent performance characteristics. fer only the pages of the object that cations and cardinality. Often, ob- These classes are available for di- are actually used. Conversely, many jects have embedded collections. rect use, but it should never be nec- small objects can reside on a single For example, a Person object might essary to work with representations page. Since locking granularity is contain a set of children. In these directly. Instead, a representation is on a per-page basis, the advantages cases, cardinalities are usually normally selected automatically, of clustering are also realized in small, often 0 or 1, and only occa- based on user-supplied estimates of decreased locking overhead. sionally above 5-10. Collections are access patterns (i.e., how frequently ObjectStore depends on the op- also used to store all objects of some various operations will be carried erating system to control the map- type, e.g., all employees, and such OUt). ping and protection of pages, and collections can be arbitrarily large. Operations on collections appear to allow access violations to be han- Furthermore, access patterns differ as methods, (or member functions, to dled by software. The most stan- greatly among applications, and use the C++ terminology). As is dard versions of Unix, such as even over time within a single ap- typical of object-oriented lan- SVR4, OSF/I, Berkeley bsd 4.3, plication. Clearly, a single repre- guages, there is a run-time function and SunOS all provide these facili- sentation type will be inadequate dispatch, to locate the appropriate ties. For other versions of Unix, when performance is a concern, so implementation of each function, ObjectStore includes a device multiple representations of collec- based on the collection's behavior driver that must be linked with the tions must be supported. However, and representation. When a collec- kernel when ObjectStore is in- it is not desirable for the user to tion modifies itself to employ a dif- stalled. ObjectStore never modifies have to deal with these representa- ferent representation, it actually the Unix kernel itself. Future ver- tions directly. The user should be modifies its own (representation) sions of these operating systems are able to work through an interface type description, so function dis- expected to provide these memory that reflects behavior, not repre- patches will continue to work cor- manipulation facilities. ObjectStore sentation. rectly. currently runs on Sun 3 and The ObjectStore collection facili- SPARC, under SunOS, IBM RS/ ties are arranged into two class hi- Queries 6000, under AIX, DEC DS3100, erarchies: one for collections, and Syntactically, queries are treated as under Ultrix, HP series 300, 400, another for cursors. The base of ordinary expressions in an ex- and 700, under HP/UX. By the end the collection hierarchy is os_collec- tended C++. However, query of 1991, ObjectStore should also be tion, which is actually the base for expressions are handled quite dif- running on DEC under VMS, and two hierarchies. One of these con- ferently from other kinds of ex- SGI. Most other popular kernel- tains os_set, os_bag, and os_list. pressions. The obvious implemen- based operating systems, including These provide familiar combina- tation strategy--iterate and check VMS and OS/2, provide the facili- tions of behavior. Other combina- the predicate--would provide very

COMMUNICATIONSOF THE ACM/October t991/Vol.34, No.10 ~9 poor performance for large collec- variable or call-by-reference pa- that join terms expressed in rela- tions. In relational DBMSs, indexes rameter), or result from the evalua- tional queries. Since the path is can be supplied to permit more ef- tion of an expression. This means materialized in the database, with ficient implementations. A query that multiple strategies must be inter-object references and embed- optimizer examines a variety of generated, with the final selection ded collections, join optimization is strategies and chooses the least ex- left until the moment the collection less of a problem. pensive. ObjectStore also uses in- being queried is known, and the In ObjectStore, a parse tree rep- dexes anti a query optimizer. The query is to be run. resenting the query is constructed indexes :are more complex than Relational database schemas are at compile-time. Information con- indexes in a relational DBMS, since heavily normalizedithere are no cerning paths that appear in the they may index paths through ob- such things as embedded sets or query is propagated up the tree to jects and collections, not just fields pointers. As a result, queries in- the nodes representing queries. directly contained in objects. The volve multiple tables whose con- During code generation, a pair of query optimization and index tents are related to one another by functions is generated for each maintenance ideas presented here ~join terms', i.e., expressions involv- node in the query's parse tree. One were inspired by [14]. Similar ideas ing rows from a pair of tables (e.g., is used to implement a scan-based on indexing and paths appear in the department identifier column strategy (visit each element and [12, 15, 16]. in the Employee table and the iden- check the predicate), and the other Optimization techniques devel- tifier column in the Department implements an index-based strat- oped for relational DBMSs do not table). Consequently, optimizers egy. Functions corresponding to seem we]ll-suited for ObjectStore. spend most of their time figuring query nodes also contain code to In a relational DBMS, relations are out the best way to evaluate queries examine the collection being que- always identified by name. As a re- with multiple join terms. In Ob- ried, (e.g., what indexes are pres- sult, information about the relation, jectStore, queries tend to be over a ent? what is the cardinality?) and e.g., the .available indexes, is avail- small number of top-level (i.e., make final choices about strategy. able when the query is optimized, nonembedded) collections, usually This approach allows for flexibility and a single strategy can be gener- one. Selection predicates involve at run time, yet still carries out ated. In ObjectStore, collections are paths through objects and embed- much expensive work (analysis of often not known by name. They ded collections. These paths ex- the query) at compile time. may be pointed at (e.g., by a pointer press the same sort of connections If ObjectStore's C+ + compiler is used, then query parsing and opti- mization occurs during compile O0 time. Queries expressed using the 94 library interface are actually parsed and optimized at run time. The mwarm same run-time library supporting 80 query execution is used in both i I cold cases. As noted earlier, paths can be viewed as precomputed joins. In 60 ObjectStore, indexes can be created on paths. As a result, the join opti- mization problem faced by rela- 40 tional DBMS optimizers is replaced by a much simpler index selection problem. Analysis of the query in- dicates which indexes could be rele- 20 ,, l ill , vant. For example, this query finds 13 84 employees who earn over $100,000 and work in the same department as Fred. oodbl ObjectStore oodb3 oodb4 rdbmsl index employees[: salary > 100000 && System dept-->employees[: name = = 'Fred' : ] : ] There are two paths here--one Warm and cold cache traversal results on salary, and another starting at

60 October 1991/VoL34, No.10/COMMUNICATIONSOF THE ACM an employee--passing through the ments are related by comparing at- the schema of the database. (But department of the employee, the tributes. It is more common to have recompilation would always be re- set of employees of that depart- queries over a single top-level col- quired.) ment, and the name of each such lection, with nested queries on Index maintenance is further employee. An index for each path embedded collections (i.e., queries complicated by the presence of in- either exists or it does not--the over paths that may go through col- dexes on paths. For example, con- choice can be made quickly at run lections). The ObjectStore query sider an index on children's names time. There is no need to reason optimizer reflects this. for a set of people. Such an index is about strategies based on the pres- While join optimization is less of useful for queries such as "Find ence or absence of an index for a problem, compared to a relational people who have a child named each step of each path, as in a rela- DBMS, index maintenance is much Fred." Index updates are required tional optimizer. more difficult. In a relational when a person is added to the col- This is not to say that queries DBMS, updates affecting indexes lection, a person in the collection over paths avoid all query process- are expressed in SQL. In Ob- has a child, or when one of this per- ing problems due to the presence of jectStore, where the integration son's children changes his or her joins. In general, a comparison of a between the DBMS and the host name. path to a constant (e.g., dept--> language is much tighter, updates Indexes on paths could be single- name == 'Research'), involves are ordinary expressions that have step, with an access method (e.g., index selection only. Join optimiza- certain side effects. For example: hash table) used to represent each tion problems occur when two step of the path, or there could be Person* p; paths are compared, as in this one structure recording the associa- query (not based on any object tion for the entire path. These al- classes described previously): ternatives have been discussed in p-->age = p-->age + 1; [14]. ObjectStore uses a series of projects[: The assignment statement up- single-step indexes. When an in- engineers[: dates the age of person p. If dexable data member is updated, proj_ld = = works_on && p->age happens to be the key to all affected access methods are name -- = 'Fred' : ] : ] some index, then that index must updated. Then, all access methods This query find projects involv- be updated. It is not practical to downstream in affected index paths ing Fred. There is no stored con- check if index maintenance is re- are updated too. Similarly, an up- nection between projects and engi- quired for every statement that date to a collection triggers updates neers. They are matched up by modifies an object. The perfor- that may affect all access methods comparing the proJAd of a Project mance consequences would be dis- of all indexes of the collection. and the works_on field of an Engi- astrous. Instead, ObjectStore re- neer. ObjectStore would evaluate quires the declaration of data Applications this join using iteration over proj- members that could potentially be The performance and productivity ects, and an index lookup on engi- used as index keys. Index mainte- benefits of ObjectStore have been neers, (assuming the index is avail- nance checks are performed for demonstrated in a number of Ob- able). An index on engineers' these data members only. Example: jectStore applications. names could also be used. class Person While this query is a valid Ob- { Performance Benefits jectStore query, it is an unusual The Cattell Benchmark [5] was de- one, and it reflects an unusual Ob- signed to reflect the access patterns int age tmde~ble! jectStore schema. Normally, the of engineering (e.g., CASE and int height; connection between projects and CAD) applications. The benchmark engineers would be represented by }; consists of several tests, but only the inter-object references, i.e., the join traverse test results are shown here would be precomputed and stored The declaration of age as index- since it best illustrates the perfor- in the participating objects. This is able indicates that updates of age mance benefits of ObjectStore's justified by analysis of programs in need to be checked for index main- architecture. The test traverses a our application domains. True tenance. Updates of height do not graph of objects similar to one that joins, as in the earlier query, are have to be checked. The indexable might be found in a typical engi- quite rare. For this reason we have declaration does not affect type. As neering application (e.g., a not yet implemented join optimiza- a result, most changes in in- schema). The graph in Figure 6 tion. It is unusual to have queries dexability (adding or removing a shows that the warm and cold cache involving multiple 'top-level' coilec- declaration of indexable to an ex- traversal results when the client and tions, (e.g., class extents) whose ele- isting data member do not affect server are on different machines

COMMUNICATIONSOF THE ACM/October 1991/Vo1.34, No.10 61 (i.e., the remote case). Access Method (ISAM)-based file under development include: A cold[ cache is an empty cache, system. • Schema evolution: When a type as would exist when a client starts Porting Cadillac to ObjectStore definition changes, instances of accessing part of the database for took one developer one week. The the type, stored in the database, the first time in recent history. A modifications were limited to three need to be modified to reflect the warm cache is the same cache after source files out of several dozen change. a number of iterations have been and involved, for the most part, dis- • Support for heterogenous archi- run. If the next iteration accesses abling the persistence mechanism tectures: Some applications re- the same part of the database, the that had been in use. The simplicity quire access to a database from cache is said to be warm. The dif- of the port was due in large part to multiple architectures with vary- ference between cold and warm the architecture of ObjectStore, ing memory layouts (e.g., differ- cache times demonstrates that both which treats persistence as a storage ent byte orderings and floating- the client cache and the virtual class rather than as an aspect of point representations). memory-mapping architecture type. The conversion would have • Communication with existing have a significant performance been much more difficult if func- databases: Many applications benefit. tions that manipulated objects had require the ability to access exist- Cold cache times are dominated to be modified to distinguish be- ing, nonobject-oriented databases by the time required to get data tween persistent and transient ob- (e.g., SQL and IMS databases). from the disk of the server into the jects. To retain the productivity bene- client's address space. Warm times In order to speed the porting fits of ObjectStore, it is necessary reflect processing speed of data process, the developers chose to al- to provide transparent access to that is already present at the client locate all objects in the database, these databases, i.e., through the and mapped into memory. We be- even those that did not need to be existing ObjectStore interface. lieve this to be the most important persistent. Once fine-grained tun- performance concern for our tar- ing commenced, however, objects get application areas. and values that could be allocated Conclusions transiently were allocated on the ObjectStore was designed for use in ProductlvlW Benefits transient heap. Transaction bound- applications that perform complex The productivity benefits are dem- aries were also added to shorten manipulations on large databases of onstratecl by the experiences of transactions, minimizing commit objects with intricate structure. Lucid, Inc., which is developing an time and reducing concurrent con- Developers of these applications extensible C++ programming en- flicts. require high productivity through vironment named Cadillac [7]. The The performance of Cadillac ease of use, expressive power, a environment has been under devel- improved considerably following reusable code base, and tight inte- opment since 1989 and will be re- the installation of ObjectStore. gration with the host environment. leased as a product. The system is Compilation from within the Cadil- However, even more important is being implemented in C+ +. lac environment ran three to five the need for high performance. Before ObjectStore was available, times faster with ObjectStore than Speed cannot be sacrificed to obtain the dew.qopers of Cadillac used a with the original ISAM-based per- these benefits. C++ object class which, when in- sistence mechanism. Compilation is The key to meeting these re- herited, provided persistence. a write-intensive operation, split quirements is the virtual memory- Classes that might have persistent into two transactions, one for each mapping architecture. Because of instances had to inherit from this pass of the compiler. Read-inten- this architecture, ObjectStore users class. For each such class, methods sive operations showed even more deal with a single type system. This (i.e., functions) for storing and re- improvement, running 10 times permits tight integration with the trieving the object from the data- faster using ObjectStore. host environment, ease of use, and base had to be defined. A reference the reuse of existing libraries. to an object resulted in a retrieval Work in Progress Other approaches to persistence from the database, if the object had Object Design, Inc. was founded in taken by other object-oriented not already been retrieved. While August 1988, and version 1.0 of DBMSs require transient and per- reads were transparent in that no ObjectStore was released in Octo- sistent objects to be typed differ- special functions had to be called by ber 1990. Version 1.1, described ently. As a result, conversion be- the class user, writes had to be ex- here, was released in March 1991 tween transient and persistent plicitly specified as function calls-- and was the result of approximately representations are required, or a process that was prone to error. 30 person-years of effort. software that had been developed This mechanism was supported by We are extending this work in a to deal with transient objects must a conventional Index Sequential number of ways. New features be modified or duplicated to ac-

6~ October 1991/Vol.34, No.10/COMMUNICATION8 OF THE ACM commodate persistent objects. In a ming environment. In Conference terns]: Database Management--Logical relational DBMS, all persistent data Proceedings of C+ + At Work. design; H.2.3 [Database Management]: is accessed within the scope of the 8. Glew, A. Boxes, links and parallel Languages--Query languages; H.2.4 trees. In Proceedings of the April '89 [Database Management]: Systems-- SQL language with its own inde- Usenix Software Management Work- Query processing, transaction processing; pendent type system. shop. H.2.8 [Information Systems]: Database The virtual memory-mapping 9. Goldstein, I.P. and Bobrow, D. A Management--Database applications architecture also leads to high per- layered approach to software de- General Terms: Design, Management formance. References to transient sign. Xerox PARC CSL-80-5, Dec. Additional Key Words and Phrases: and persistent objects are handled 1980. C++, database (persistent) program- by the same machine code se- 10. Goldstein, I.P., Bobrow, D. An ex- ruing languages, ObjectStore, object- quences. Other architectures re- perimental description-based pro- oriented programming quire references to potentially per- gramming environment: Four re- sistent objects to be handled in ports. Xerox PARC CSL 81-3, Mar. About the Authors: 1981. software, and this is necessarily CHARLES W, LAMB is a member of 11. Kazar, M.L. Synchronization and the engineering staff and co-founder of slower. caching issues in the Andrew file Object Design. He was previously an ObjectStore's collection, relation- system. In Usenix Conference Proceed- employee of Symbolics, where he ship, and query facilities provide ings, (Dallas, Winter 1988), pp. 27- worked on the design and implementa- support for conceptual modeling 36. tion of the Statice object-oriented data- constructs such as muhivalued at- 12. Kemper, A., Moerkotte, G. Access base system. tributes, and many-to-many rela- support in object bases. In Proceed- tionships can be translated directly ings ACM SIGMOD International GORDON LANDIS is a member of the into declarative ObjectStore con- Conference on Management of Data engineering staff of Object Design. He structs. [] (1990). was previously a co-founder of On- 13. Maier, D. Making database systems tologic, where he led the design and References fast enough for CAD applications in implementation of the Vbase object- 1. Agrawal, R., Gehani, N.H. ODE object-oriented concepts, database oriented database system. ( and environment): and applications. W. Kim and F. The language and the data model. Lochovsky, Eds., Addison-Wesley, Reading, Mass., 1989, pgs. 573- JACK A. ORENSTEIN is a member of ACM-S1GMOD 1989 International the engineering staff and co-founder of Conference on Management of Data 581. 14. Maier, D., Stein, J. Development Object Design. He was previously a (May-June 1989). computer scientist at Computer Corpo- 2. Bancilhon, F., Maier, D. Muhilan- and implementation of an object- oriented DBMS. In Research Direc- ration of America, where he conducted guage object oriented systems: New research on spatial data modeling and answers to old database problems. tions in Object-Oriented Programming, B. Shriver and P. Wegner, Eds., spatial query processing on the PROBE Future Generation Computers H, project. K. Fuchi and L. Kotti, Eds., North- MIT Press 1987. Also in Readings in Holland, 1988. Object-Oriented Database Systems, S.B. 3. Biliris, E. Configuration manage- Zdonik and D. Maier, Morgan DANIEL L. WEINREB is a Database ment and versioning in a CAD/ Kaufmann, Eds., 1990. Architect and co-founder of Object De- CAM data management environ- 15. Shekita, E. High-performance im- sign. He was previously a co-founder of ment (An example). Prime/Com- plementation techniques for next- Symbolics, where he led the design and putervision internal memo, June generation database systems. Com- implementation of the Statice object- 1989. puter Sciences Tech. Rep. #1026, oriented database system. 4. Carey, M.J., Franklin, M.J., Livny, University of Wisconsin-Madison, M., Shekita, E.J. Data caching 1991. trade-offs in client-server DBMS 16. Shekita, E., Carey, M. Performance Authors' Present Address: Object architectures. In Proceedings ACM enhancement through replication Design, Inc., One New England Execu- SIGMOD International Conference on in an object-oriented DBMS. In tive Park, Burlington, MA 01803; email: the Management of Data (1991). Proceedings ACM SIGMOD Interna- [email protected] tional Conference on Management of 5. Cattell, R.G.G. and Skeen, J. Object Data (1990). Permission to copy without fee all or part of operations benchmark. ACM Trans. this material is granted provided that the Database Syst. To be published. copies are not made or distributed for direct 6. Chou, H., Kim, W. Versions and CR Categories and Subject Descrip- commercial advantage, the ACM copyright change notification in an object- tors: C.2.4 [Computer Systems Organi- notice and the title of the publication and its oriented database system. In Pro- zation]: Computer-Communication date appear, and notice is given that copying Networks--Distributed systems; D.3.2 is by permission of the Association for ceedings of 25th ACM/IEEE Design Computing Machinery. To copy otherwise, or Automation Conference (1988). [Software]: Programming Languages-- to republish, requires a fee and/or specific 7. Gabriel, R.P., Bourbaki, N., Devin, Language classifications; D.4.2 [Soft- permission. M., Dussud, P., Gray, D., Sexton, H. ware]: Operating Systems--Storage Foundation for a C++ program- management; H.2.1 [Information Sys- ©ACM0002-0782/91/1000-050 $1.50

COMMUNICATIONS OF THE ACM/Octobcr 1991/Vol.34, No.10 63