Performance Improvement Techniques

You can improve the performance of your gateway by implementing the following techniques:

Create a queue of tokens in your gateway driver’s VgwStreamNewFnc function and return them, one at a time, from your gateway driver’s VgwStreamGetTokenFnc function. This technique can reduce network I/O and calls by the Verity engine to other functions in your gateway driver.

 

Always start streaming with a VdkTokenType_ContentType token, which identifies the content’s format, followed by a field token for the internal Charset field. This technique prevents the Verity engine from attempting to auto-detect the format or the character set, which is time-consuming and, potentially, error-prone. You must start with a content-type token; otherwise, the Verity engine attempts auto-detection of the content type and character set anyway. For more information, see Bypassing Auto-Recognition.

 

Create an access control list when indexing a collection and store the ACL field in the collection. The collection field should only be used by your gateway driver’s VgwSecurityCheckDocs callback function to speed up searching; it should not be used by your gateway driver’s VgwDocExist callback function, which is called during viewing, because you need to prevent a user from knowing that a document exists during the search. This technique speeds up searching because the ACL has already been created.

 

Use the stream interface and field tokens to index a collection; avoid using the copy statements in your style file for collection fields that are always present, such as an access control list, the external key (VdkVgwKey), and so on. The field interface, which is invoked by copy statements during indexing, is much slower than the stream interface.

 

 

   
  Note   You must use a copy statement with the _SECURITY field because it is used differently than other fields in a collection.
   

 

Reduce the number of tokens you create; for example, for viewing you seldom need to create field and zone tokens.

 

Keep per-driver data structures in global memory; for example, non-session specific handles, such as connection handles, handles to open databases, and so on. This technique provides faster access to frequently-used structures than re-initializing them each time the Verity engine calls your gateway driver’s VdkDrvNew function.

 

 

   
  Note   You must guarantee that structures in global memory are thread-safe; for more information, see Accessing Global Storage. You must also provide a way to remove “stale” structures from global memory; for example, by time-stamping structures and using a timeout value or least-recently-used algorithm to limit their existence.
   

 

Keep per-session and per-stream data structures in global memory; for example, structures that are identified through the respective callback arguments, such as a session’s style-file settings or a queue of tokens for a stream. This technique is similar to keeping per-driver structures in global memory, and provides faster access to frequently-used structures than recreating them each time the Verity engine calls your gateway driver’s VgwSessionNew or VgwStreamNew functions. You must implement thread-safety within the context of the session or stream.

 

Keep per-user data structures in global memory; for example, the user’s group, role, or access rights. This technique is similar to keeping per-driver structures in global memory, and provides faster access to frequently-used information than re-initializing it using the user’s certificate. You must implement thread-safety within the context of the certificate.