INFORMIX
Extending INFORMIX-Universal Server: User-Defined Routines
Chapter 5: Performance Considerations
Home Contents Index Master Index New Book

Memory Considerations

This section describes stack-size considerations and the virtual-memory cache for routines.

Stack-Size Considerations

The database server allocates local storage in user-defined routines from shared memory. As a result, a user-defined routine must not consume excessive stack space, either through large local-variable declarations or through excessively long call chains or recursion. A function that overruns the shared-memory region allocated for its stack overwrites adjacent shared memory, with unpredictable and probably undesirable results.

In addition, any nonstack storage allocated by a thread must be in shared memory. Otherwise, the memory is not visible when the thread moves from one VP to another.

The database server dynamic function manager guarantees that a large stack region is available to a thread before it calls a user-defined function, so stack exhaustion is generally not a problem.

In addition, the DataBlade API provides memory-management routines that allocate space from shared memory, rather than from process-private memory. If you use the DataBlade API interfaces, memory visibility is not a problem. For more information on the DataBlade API, refer to the DataBlade API Programmer's Manual.

Setting Stack Sizes for User-Defined Routines

When you specify a stack size for a user-defined routine, the server allocates the specified amount of memory for every execution iteration of the routine. If a routine does not need a stack larger than 32 kilobytes, do not specify a stack size.

Virtual-Memory Cache for Routines

Universal Server caches the following items in the virtual portion of the database server shared memory:

System Catalog Cache

When any session requires the use of an SPL routine for the first time, the database server reads the sysprocedures system catalog tables and stores the information in the virtual portion of shared memory for the database server. The database server uses this information in shared memory if it is present for subsequent sessions that invoke the SPL routine.

The database server keeps this sysprocedures system catalog information in the virtual memory cache on a most recently used basis.

The sysprocedures table includes the following information:

SPL Cache

When any session requires the use of an SPL routine for the first time, the database server reads the system catalog tables to retrieve the code for the SPL routine. The database server converts the pcode into an executable form. The database server caches this executable form of the SPL routine in the virtual portion of shared memory.

The database server keeps this executable format of an SPL routine in the virtual-memory cache on a most recently used basis.




Extending INFORMIX-Universal Server: User-Defined Routines, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.