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

Choosing a Virtual-Processor Class

You must choose the virtual-processor (VP) class in which to run the user-defined routine. User-defined routines run in the CPU VP by default.

CPU Virtual-Processor Class

Generally, user-defined routines perform best in the CPU VP because threads do not have to migrate among operating-system processes during query execution.

However, CPU VP execution requires additional programming. You must make sure that your code adheres to the following guidelines:

User-Defined Virtual-Processor Class

You can designate user-defined classes of virtual processors, called Extension (EXT) VPs, to run user-defined routines.

Running in an Extension VP relaxes some, but not all, of the programming requirements. These routines can perform blocking operations, but they still cannot perform local resource allocations because they might migrate among the VPs.

Routines that run in a user-defined virtual processor class need not yield the processor, and they might issue direct file-system calls that block further processing by the virtual processor until the I/O is complete. Because virtual processors are not CPU virtual processors, however, the normal processing of user queries is not affected.

This option results in lower performance because queries normally execute in the CPU VP, and the query thread must migrate to the EXT VP to evaluate user-defined routines. Thus, you should use the EXT VP with caution.

Defining an Extension Virtual-Processor Class

You might want to define a user-defined class of virtual processors to run DataBlade or user-defined routines. When you register a user-defined routine or function, you assign it to a class of virtual processors with the CLASS parameter of the CREATE FUNCTION statement. For example, the following CREATE FUNCTION statement registers the user-defined routine, GreaterThanEqual and specifies that calls to this routine should be executed by the user-defined VP class named new:

Tip: You can use the CREATE FUNCTION statement to create routines or functions that reference any user-defined class that you like, and the class need not exist when the function is created. However, if you try to use a function that refers to a user-defined class, the class must exist and have virtual processors assigned to it. If the class does not have any virtual processors, you receive an SQL error.

Configuring an Extension Virtual-Processor Class

You configure new virtual-processor classes in the ONCONFIG file. When you configure a new class of user-defined virtual processors to run user-defined routines, you must ensure that the name of the class agrees with the name that you assigned in the CREATE FUNCTION statement.

The following example creates the user-defined class new, for which the database server starts three virtual processors initially:

The database server executes user-defined routines that you register with the CLASS = `new' clause in the new virtual-processor class. The class name is not case sensitive. It appears in the onstat -g glo output as a new process.

Important: If you create a new virtual-processor class, you must remove the SINGLE_CPU_VP parameter from the ONCONFIG file.

Using the noyield Option

The noyield option causes a user-defined class of virtual processors to run user-defined routines in a way that gives the routine exclusive use of the virtual-processor class. In other words, user-defined routines that use a noyield virtual-processor class run serially, and each routine runs to completion before the next one begins.

You should assign a user-defined routine to a nonyielding class of virtual processors if the routine has not been designed or coded to handle the concurrency issues of multiprocessing. For example, if a user-defined routine uses global variables and makes calls to database services, such as the smart- large-object interface, you should assign it to a nonyielding class of user-defined virtual processors. Similarly, a call to a database can cause the processing thread to yield for I/O operations. Yielding allows another thread to run the same code and change the states of variables that the original thread assumes to be stable when it resumes processing.

This option is ignored for pre-defined virtual-processor classes such as CPU, AIO, and so on.

The following example specifies a user-defined class of virtual processors called new, that run in noyield mode:

Adding and Dropping User-Defined Virtual Processors in On-Line Mode

You can add or drop virtual processors in a user-defined class while Universal Server is on-line. Use onmode -p to add virtual processors to the class. The following command adds three virtual processors to the new class:

For more information on how to assign a user-defined routine to either CPU or user-defined classes of virtual processors, refer to the CREATE FUNCTION statement, and specifically to the CLASS parameter, in the Informix Guide to SQL: Syntax.




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