CONFIGURATION TUNING 263 273 Hari Ram Kumar Bolisetti
CONFIGURATION & TUNING (263 - 273) Hari Ram Kumar Bolisetti Presentation #21
CONTENT Reflection-Related Configurations Ø Communication-Related Configurations Ø Logging-Related Configurations Ø Miscellaneous Configurations Ø A Glimpse into the Ext. Object. Container Ø External Tools Ø Tuning for Speed Ø
REFLECTION-RELATED CONFIGURATIONS ØTo store and restore objects, db 4 o relies on several reflection mechanisms. db 4 o has to check that the objects in the database match the objects in your class path ØOther examples deal with constructors and query optimization. Call. Constructors(bool flag) If you are using a modern. NET or Java virtual machine, then it can be possible to instantiate the objects without calling constructors. C# - Db 4 o. Configure(). Object. Class(typeof(Foo)). Call. Constructors(true); JAVA - Db 4 o. configure(). object. Class(Foo. class). Call. Constructors(true);
Detect. Schema. Changes(bool flag) When you want a fast startup and you are sure that the database file is “in schema sync” with the classes on your classpath, you should call, Detect. Schema. Changes(false). Optimize. Native. Queries(bool optimize. NQ) If the required libraries are in your class path, you can set true and your queries will be optimized dynamically. true is the default value. Reflect. With(Reflector reflector) This configuration allows you to set an alternative reflector. If you are using Java, for example, then by default java. lang. reflect is used.
Refresh. Classes() This configuration enforces that all classes be reanalyzed again. If this method is called on the global configuration context, the classes in all db 4 o sessions will be refreshed Set. Class. Loader(Class. Loader class. Loader) This configuration sets a new classloader. db 4 o usually runs with the default classloader and knows its classes from its classpath. Test. Constructors(bool flag) This configuration method is tightly coupled to the Call. Constructors configuration. You can implement a public constructor and set Call. Constructors to true to achieve better performance.
COMMUNICATION-RELATED CONFIGURATIONS 1. Get. Message. Sender() Message. Sender message. Sender = object. Container. Ext(). Configure(). Get. Message. Sender() 2. Set. Message. Recipient(Message. Recipient message. Recipient) db 4 o. Server. Ext(). Configure(). Set. Message. Recipient(this); 3. Single. Threaded. Client(bool flag) - This timeout configuration is used to configure the client side to wait only a specific time for a server response 4. Timeout. Client. Socket(int milliseconds) - The server is constantly watching its clients to see if they are alive or not. 5. Timeout. Server. Socket(int milliseconds) - To receive messages, the server starts multiple socket-read threads.
LOGGING-RELATED CONFIGURATIONS Ø db 4 o does not have a perfect logging integration yet. We just see how db 4 o works and leave the logging system quiet due to performance aspects. Message. Level(int level) Ø One of the easiest configurations. This configuration sets the message level of the db 4 o logging. Db 4 o. Configure(). Message. Level(0); Ø Level 0: No messages will be logged. (silence) Ø Level 1: Only open and close messages will be logged. Ø Level 2: New, update, and delete actions will be logged too. Ø Level 3: Messages for activation and deactivation will be
Set. Out(Print. Stream out. Stream) It lets you select a print stream for db 4 o logging, either the console or some other stream. For example, The following prints out to the console, which is the default: Ø Db 4 o. Configure(). Set. Out(new j 4 o. io. Print. Stream(System. Console. Out)); // C# Ø Db 4 o. configure(). set. Out(System. out); // JAVA
MISCELLANEOUS CONFIGURATIONS � Automatic. Shut. Down(bool flag) This configuration value is true by default, meaning that the Object. Container will perform a shutdown if the JDK terminates or it has no references and it is garbage collected. �Exceptions. On. Not. Storable(bool flag) Whether or not an object can be instantiated depends on the availability of the constructors and on the virtual machine used. � Freespace() This configuration returns the free space configuration interface. This interface has three interesting methods: 1. Use. Ram. System() 2. Use. Index. System() 3. Discard. Smaller. Than(int byte. Count)
A GLIMPSE INTO THE EXTOBJECTCONTAINER • Bind: Called as Bind(Object, id), this methods loads the object with the id into memory and replaces this memory reference with the object that has been given as a parameter. • Get. By. ID: Gets an object when passing the long ID. • Get. ID: Gets the ID when passing the object. • Get. Object. Info: Returns an object information object that can be used to get the UUID and the transactional version number. • Is. Active: Tests if an object is active (true). If it is not stored within the object container, then false will be returned. • Is. Cached: Tests if the object behind the passed ID is cached. • Is. Stored: Tests if the object is already stored in this container.
EXTERNAL TOOLS db 4 o provides a further set of tools in the form of classes in the namespace/package com. db 4 o. tools. Defragment � Defragment deletes unused fields and management information. The resulting database file is smaller and ready for faster access. � There are two ways to initiate a defragmentation. 1. First, the Defragment class has a Main method, so it can be executed directly from the command line. 2. The second one is a Boolean that indicates whether or not the original file should be deleted.
Statistics This class simply prints statistics about a database file. Here’s an example of statistics for a very small database that contains a single Person object: ******* STATISTICS ******* File: c: /db. yap ******** CLASSES ******** Number of objects per class: com. db 4 o. dg 2 db 4 o. chapter 10. Person: 4 com. db 4 o. Meta. Class: 0 com. db 4 o. Meta. Field: 0 com. db 4 o. Meta. Index: 1 com. db 4 o. P 1 Object: 0 com. db 4 o. PBoot. Record: 0 com. db 4 o. Static. Class: 0 com. db 4 o. Static. Field: 0 com. db 4 o. ext. Db 4 o. Database: 1 ******** SUMMARY ******** File: c: /nq. yap Stored classes: 9 Total number of objects: 6
Logger This class simply logs the objects in a database file. java com. db 4 o. tools. Logger db. yap Here’s an example of logging for a very small database that contains four Person objects: com. db 4 o. db 2 db 4 o. chapter 10. Person. _name: Mandela. Person. _age: 86 com. db 4 o. db 2 db 4 o. chapter 10. Person. _name: Teresa. Person. _age: 86 com. db 4 o. db 2 db 4 o. chapter 10. Person. _name: Lincoln. Person. _age: 56 com. db 4 o. db 2 db 4 o. chapter 10. Person. _name: Gandhi. Person. _age: 79 Log complete. Objects: 4
TUNING FOR SPEED Dos and don’ts you should take into account when tuning db 4 o for speed. � Set the activation and deletion depth exactly to match the size of your needs. � Turn weak references off. If you only write or query, then you may well not need them. � The classes on startup for the availability of a zero-parameter constructor.
THANK YOU !!
- Slides: 15