This section contains tips for optimizing the performance of your adapter.
In most cases, in-process adapters process multiple rows (if available) each time the execute() function is called. This can dramatically improve performance. The Server runs each adapter on a separate thread. Each thread runs in a loop that does the following:
Call the adapter's execute() function, and waits for the execute() function to return.
Sleep. By default, on most platforms the thread sleeps for 1 millisecond (1/1000 of a second).
This means that the execute() function can be called no more than 1000 times per second. If the adapter processes only one row per call, then the adapter can process no more than 1000 rows per second.
If data is available to be processed, the adapter should try to process multiple rows per call. This can increase performance by a factor of tens or hundreds. However, the adapter should not process so many rows that it prevents the server from having enough CPU time, either.
Experiment to find the optimal number of rows to process per call, depending on your hardware, the other processes that are running on your computer. A general rule is to try to process 30-100 rows per call and then experiment with increasing or decreasing the number of rows per call to find where performance is best.
You can also write the adapter so that rather than processing a fixed number of rows per call, the adapter will listen for interrupt requests from the server. Your adapter can call the function C8AdapterIsInterrupted() to see whether the server would like the adapter to yield control of the CPU. See In-process Adapter API for a description of the function. See In-process Output Adapters for sample code that uses this function.
When you want to change the number of rows sent per call to the execute() function. In some cases, you may also want to adjust the sleep interval in between calls to the execute() function. This sleep value is used by the framework between calls to the execute function. You can get and set this sleep interval value by using the following functions:
C8AdapterGetSleepInterval().
C8AdapterSetSleepInterval().
These functions are defined in c8adapter_in_process.h.