Nonblocking I/O processing has been incorporated into the HP NonStop Operating System, Mission Critical Edition, in release version updates (RVUs) J06.04 and H06.15. Nonblocking I/O processing enables NonStop application developers to achieve even greater levels of concurrency in multithreaded applications, thereby achieving optimum application performance.
Background
Application developers have long used multithreading application programming interfaces (APIs) in NonStop applications to increase application performance by increasing concurrency levels. Using multiple threads, application developers divide applications into execution units that operate in parallel. Because these multiple threads still execute within the context of a single process, they can share process state information.
For example, a server process that receives client requests can spawn new threads to handle each individual request. Since each request is independent of the others, the spawned threads can process individual requests. And since all the threads execute within the context of a single process, the main thread and the spawned threads can communicate through process-global data structures and share process-global resources. The net effect is that request processing can occur in parallel, thereby greatly increasing the throughput of server processes.
Nonblocking I/O
The IEEE POSIX 1003.1c standard defines a standard set of threading APIs called pthreads. pthread APIs are supported on open systems such as Linux, various flavors of UNIX, and the NonStop Open System Services (OSS) environment.
Nonblocking I/O processing utilizes pthreads to ensure that when a thread in a multithreaded application performs I/O processing on a regular file, the other threads in that process are able to continue executing as long as they don’t interfere with the regular file being acted against. Previously, when a thread in an application performed I/O processing on a regular file, all the threads in the applications were blocked until that I/O process completed. Now, by allowing the other threads to execute in parallel, the application is able to achieve greater levels of concurrency.
A note about serialized operations
Operations that modify process state information associated with the open file are serialized. That is, only one thread at a time is allowed to execute operations per open file. For example, the write() and read() operations are serialized because they modify the current file position associated with the file open. To illustrate, if a file is opened and a write() of 80 bytes occurs, the current file position will be set to byte 81 and the next read() operation of 10 bytes will begin at byte 81 and will set the current file position to byte 91. Because the file state is associated with an open file, serialization only occurs when threads are accessing the same opened file. As a result, for optimum performance, applications should be written so that threads access different files.
Enabling Nonblocking I/O
You can enable the nonblocking I/O feature in the NonStop OSS environment by calling the new nonblocking I/O APIs listed below. In regular OSS files, these APIs block only the calling thread—not the process itself—if they are required to wait for an I/O operation to complete. In this way, throughput of multithreaded applications is improved.
spt_fcntlz( )
spt_ftruncate64z( )
spt_fsyncz( )
spt_ftruncatez( )
spt_readvz( )
spt_readz( )
spt_writevz( )
spt_writez( )
spt_closez( )
spt_fstat64z( )
spt_fstatz( )
spt_lseek64z( )
spt_lseekz( )
Recompile existing applications for better performance
If an existing OSS application is written to call the standard C I/O functions like read() and write(), then these applications can take advantage of nonblocking I/O by recompiling.
C programs need to define SPT_THREAD_AWARE_XNONBLOCK (e.g., #define SPT_THREAD_AWARE XNONBLOCK 1) and C++ programs need to define the pragma SPT_THREAD_AWARE_PRAGMA_XNONBLOCK (e.g., #pragma SPT_THREAD_AWARE_PRAGMA_XNONBLOCK). Use of SPT_THREAD_AWARE_XNONBLOCK or SPT_THREAD_AWARE_PRAGMA_XNONBLOCK will cause C I/O functions like read() to call the new NonStop APIs like spt_readz().
Nonblocking I/O for Java™
The latest NonStop Server for Java™ 5.0 software product release (SPR) (T2766H51^ABG) supports nonblocking I/O processing for Java programs. Similar to C/C++ programs, Java programs need to be recompiled with –Dnsk.java.nonblocking=true specified as a Java compile time option. Java programs will use the nonblocking I/O feature by default in a future NonStop Server for Java release.
This news is published on NonStop Computing websites. December 2008.
|