Multi-core Support
Pervasive PSQL v11 is specifically designed to increase scalability and performance on multi-core machines. Install Pervasive PSQL v11 on a multi-core machine and the benefits are immediately available in a multiuser environment.
You may wonder “what benefits?” Increased scalability and performance are obviously desirable and assumed to be available with advances in hardware technology. Heretofore, advances in hardware technology meant advances in speed. Applications just ran faster. Today, advances in computing technology mean increased parallelism and not increased clock speeds. And that presents challenges to which your application has probably never had to contend.
The rules have not just changed because of multi-core environments, they have changed dramatically. For example, applications that share data with multiple users and use a database where transactional integrity must be maintained can run slower on multi-core processors.
Because the majority of applications using Pervasive PSQL fall into that category, multi-core support is a primary feature of Pervasive PSQL v11. It is of primary importance to you as you transition your multiuser applications into multi-core environments.
Why Multi-core Support
Without modifications, almost all software applications can run on multi-core machines. But consider the following scenario, which is based on real-world feedback:
You replace your antiquated production server with a current one. Your multiuser application gets installed on the new multi-core machine with a compatible operating system. Things should be humming better than ever. But response time is slower. Performance is worse than before the hardware upgrade.
What happened? Critical components of your business solution are no longer optimized for one another in the new world of multi-core.
Think of it this way. Your “application” comprises four main pieces: the code you wrote (application in its common definition), the database, the operating system, and the hardware. Changing the hardware has a significant impact if it fundamentally differs from its predecessors.
But tuned in the right way, applications that would otherwise be slowed down can take advantage of hardware changes and experience significant performance improvement. In many cases, swapping out portions of the application stack, such as the database, can address multi-core issues with no immediate changes required to the application. This approach provides as a low risk way to buy time while you plan longer-term strategies for application development.
Using Pervasive PSQL v11 as the database, you can realize increased performance and scalability on multi-core machines.
Performance
Pervasive PSQL v11 has been architected to provide parallel threads performing similar activities. The gains in increased parallel processing improve the throughput to the point that multiple processors are engaged. The result is that performance of the database engine increases in multi-core environments with multiple clients accessing a central server. Your multi-client application can benefit from this increased performance without requiring you to recompile or rearchitect the code.
Pervasive PSQL v11 also provides enhancements to the low-level synchronizations mechanisms in the transactional interface. Multiple users can read the same cached file pages simultaneously and their operations can proceed on independent server CPUs. Non-user activity such as checkpoints and log management can also use additional server CPUs.
Scalability
The scalability of Pervasive PSQL v11 has also been enhanced through architecture designs made specifically for multi-core hardware. For example, multiple users accessing independent files can proceed on independent server CPUs. The database engine can also handle higher user loads with less overhead, resulting in steadier throughput.
Just as with the performance improvements, all of the scalability enhancements are available without requiring you to recompile or rearchitect your code.
Configuration Settings
The majority of multi-core improvements in Pervasive PSQL v11 are transparent. You are not required to adjust any settings to further enhance the optimizations. The configuration setting “Communications Threads” has changed and can be used to fine-tune performance if you choose. See Configuration Settings.
The Multi-core Dilemma
Several common problems are at play in the multi-core world of hardware and software interaction that may cause decreased performance with your application. Among them are multiple threads and memory contention. For a thorough discussion of these and other problems, refer to the white paper The Multi-core Dilemma by Dan Woods, CTO of CITO Research. The white paper is available on the Pervasive Web site.
A brief discussion in this document of multiple threads and memory contention illustrates why multi-core support is a primary feature of Pervasive PSQL v11.
Multiple Threads
A multithreaded application does not necessarily run better on a multi-core machine. In fact, you may find that your multithreaded application runs slower.
To work correctly in parallel, the threads must be synchronized. An application can be multithreaded, but the threads themselves not synchronized. This situation is actually quite common, in which older applications spin off additional threads as needed, more for convenience than based on a design to ensure efficiency. Such applications do not run better on a multi-core machines because the threads contend with one another. Multiple cores provide no benefit because thread contention inhibits throughput to the point that multiple cores are not engaged.
Also, the multi-core architecture can perceive the subtasks that spin off the multiple thread as a series of single threads. And, just as with single-threaded programs, the threads are then forced into a single queue and processed one by one. Caching does not improve the problem; it makes it worse (see Memory Contention).
Where possible, each core should process separate data. Otherwise, the overhead associated with synchronization can slow down performance significantly. Recall that Pervasive PSQL v11 has been architected to provide parallel threads that are synchronized.
Memory Contention
When most applications were written, developers did not have to decide between parallel and non-parallel processes. The majority of applications were written sequentially, meaning that they access information serially or sequentially. A problem with memory contention occurs when running a non-parallel (typical) application on a multi-core system.
Consider the slapstick comedy skit that depicts a group of people trying to get through a single doorway at the same time. This is good for laughs because the individuals just jam together at the opening, wedged into an immovable mass. Now, image that, instead of people and a doorway, it is multiple threads trying to be processed at the same time. With four to sixteen threads (or more) trying to get through the same processor at once, a jam occurs that the operating system must sort out.
If multiple cores or processors have caches that point to the same data and one core modifies the data, the cached data on the other core is no longer valid, and the caches must be synchronized. Contention also occurs as the processors repeatedly check the caches to ensure a task on one processor does not execute on outdated data produced by another task on another processor. This checking slows processing because each processor checks the memory cache individually and sequentially.
Recall that with Pervasive PSQL v11 activities of multiple users proceed on independent server CPUs as a way to reduce memory contention. Multiple users can read the same cached file pages simultaneously and access independent files.
The Role of the Operating System
You may be wondering how much the operating system (OS) assists with the problems of multiple cores. Less than you would guess, even with current 64-bit ones.
When contention for resources happens, the OS handles the resolution. For the majority of applications, the OS handles thread contention slower on multi-core systems. That is, the OS on multi-core systems take a longer time to resolve the contention points.
Why is this? An OS optimized for multi-core does not fix your problems if your applications still require the operating system to perform tasks in a single-file fashion.
When the OS gets requests from an application that do not incorporate instructions for multi-core processing, the OS is very cumbersome at sorting out the sequence in which the requests are processed. This is analogous to a traffic jam on a highway. Conceptually, the OS asks each waiting driver whether or not they are ready to go before allowing the vehicle to proceed. Although such processing jams are occurring at the OS level, users perceive the slowdown as an application performance problem.
An application optimized for multi-core provides instructions for the OS on how to manage shared resources and determine priority for access to those resources. Information requests are organized in such a way that they do not compete for cache lines or access to central memory.
Recall that Pervasive PSQL v11 includes architecture designs made specifically for multi-core hardware. Low-level locking has been optimized for multi-core machines.
Benefiting from the Present While Planning For the Future
Multi-core machines are the norm, so any current or future hardware upgrades will include multiple cores. Operating systems have yet to catch up with multi-core machines to assist optimal performance. How best, then, to address these conditions?
Ultimately, applications will have to be rearchitected to perform optimally on multi-core machines. This allows the application to take advantage of parallel threads on multiple processors while avoiding synchronization issues.
Rearchitecting takes thoughtful planning and time to implement, perhaps even years. Meanwhile, business continues. As mentioned at the beginning of this section, multi-core support becomes of primary importance to you as you transition your applications into multi-core environments.
Your “application” consists of your code, the database, the operating system, and hardware. Hardware systems have already addressed multi-core support. Operating system provide some assistance provided your application takes advantage of the multiple cores. That leaves the database.
The multi-core features of Pervasive PSQL v11 can help offset any performance degradation your end users might experience from your application not being optimized for multi-core environments. In most cases, you can boost application performance without having to recompile or change your application code.