The yielding user-defined VP

By default, a user-defined virtual processor is a yielding VP. That is, it expects the thread to yield execution whenever the thread waits for other resources.

After a thread yields a user-defined VP, the VP can run other threads that execute UDRs assigned to this VP class. The most common use of a yielding user-defined VP class is for execution of code that cannot be rewritten to use the DataBlade® API file-access functions to perform file-system activity.

The following table summarizes the programming requirements for C UDRs that apply to execution in a yielding user-defined VP.
CPU VP safe-code requirement rule Required for yielding user-defined VP?
Yields the VP on a regular basis Recommended
Does not use blocking operating-system calls Not required
Does not allocate local resources, including heap memory Yes
Does not modify global or static data Yes
Does not modify other global process-state information Yes
Does not use restricted operating-system calls Yes
The main advantages of a yielding user-defined VP class are as follows:
  • You can use the mi_yield() function in your UDR to explicitly yield the user-defined VP.

    Failure to use mi_yield() in a UDR creates the same loss of concurrency that it would in a CPU VP. However, loss of concurrency is not as critical in user-defined VPs because these VPs do not handle all query processing, as the CPU VPs do. For more information, see Yield the CPU VP.

  • You are no longer restricted from use of blocking I/O calls in the UDR.

    The C UDR can issue direct file-system calls that block further VP processing until the I/O is complete. Because user-defined VPs are not in the same VP class as CPU VPs, this blocking does not affect concurrency of the CPU VP or threads on other VPs. The most common use of a yielding user-defined VP is to run a UDR in which it is not practical to rewrite file-system activity with the DataBlade API file-access functions. For more information, see Avoid blocking I/O calls.

Important: A yielding user-defined VP relaxes the restriction on use of blocking I/O calls. However, they do not remove the restrictions on other types of unsafe system calls. For more information, see Avoid restricted system calls.

The main disadvantage of a yielding user-defined VP is that it can reduce performance of UDR execution. Execution in the CPU VP maximizes performance of a well-behaved UDR.

For more information, see Define a yielding user-defined VP class.