Welcome!

Open Source Cloud Authors: Yeshim Deniz, Elizabeth White, Pat Romanski, Liz McMillan, Greg Schulz

Related Topics: Open Source Cloud

Open Source Cloud: Article

Multi-Core Debugging and Performance Enhancement

Additional pressures on complex applications

Identifying and fixing deadlock and livelock situations requires a good debugger. In today's multi-core multiprocessor environments, efficient debugging requires the user to navigate between processes and threads from a common environment without disturbing the program running. A debugger should operate with minimal application intrusion so that deadlock and/or livelock can be identified and fixed in real-time (e.g., applications hot-patched while the application is running). Users should also be able to stop a thread and observe the state of all the other threads running in the application.

In some cases, the events leading up to a lock situation may not be immediately apparent to a debugger or the exact timing will have to be recreated without a debugger present. To resolve these issues, it's often necessary to generate program execution traces so that actual events and interactions between threads can be examined.

A graphical event analyzer tool is ideally suited to this purpose. With such a tool, user programs and the Linux kernel can be traced live or viewed in a post-execution file. In both cases, user and kernel events can be collected from the multiple processes executing simultaneously on multiple cores and processors, and then examined to determine what caused the lock.

Race Conditions
A race condition is similar to a deadlock but can cause more subtle problems. Suppose the programmer in the example above only allows Process 1 to own the lock on Total to avoid deadlock. Now suppose all program threads can lock and add to the Sub-Total variable. If Process 1 decides to add the Sub-Total to Total at some point, it may not have all the contributions to Sub-Total. These types of situations can be hard to identify and result in the program providing different answers when using the same data.

A race condition is particularly difficult to find. Often they result from subtle timing assumptions in the program that aren't guaranteed to be true each and every time. The program will occasionally provide the wrong result. Moreover, when the programmer adds some debugging code or attaches a simple debugger and steps through code, the problem goes away. This type of behavior is often called "non-deterministic" since it "just happens" from time to time. To find these kinds of problems, a debugger must be able to examine program execution in real-time.

Again, a robust Linux debugger that allows real-time modification and monitoring of an executing program is essential to resolving race conditions. There's no need to add code or alter program behavior to find and repair problems. Another useful debugging feature is the ability to analyze and display memory allocations and de-allocations. A race condition, and deadlock/livelock for that matter, can occur when a thread behaves unexpectedly and memory management issues are often the source of such problems.

Mismatched Communication/Synchronization
As simple as it sounds, mismatched communication is often the cause of many parallel computing problems (both with threads and message passing). Communication is an essential part of parallel programs. (If parts of the program don't communicate then it would not be a parallel program!) Communication can also be used as a synchronization method. For instance, a thread may wait until another thread tells it to start or stop a task. This kind of communication is often called "blocking" and provides the programmer with some synchronization points.

The other method of communicating is called "non-blocking." In this method a task may be busy computing and occasionally checks to see if a message has arrived. While this asynchronous behavior can be more efficient than a synchronous blocking approach, it's also subject to communication deadlock and race conditions.

In either case, a communication mismatch occurs when a sender or receiver isn't available. These situations can occur by outright programming error or by using asynchronous methods like "non-blocking" communication. Similar to race conditions, asynchronous communication issues can be non-deterministic.

One way to debug communication/synchronization issues is to use a multi-thread event analyzer. This tool lets system and user-requested events be logged from multiple processes executing simultaneously on multiple processors or cores. The result is a minimal-overhead, high-resolution trace of your application behavior.

Taking Debugging to the Next Level
All of these conditions require the programmer to debug the programs deeper than ever before and at the same time touch the program very lightly. Many standard debuggers aren't prepared for this level of interaction. Indeed, the problems associated with multi-core debugging usually require attacking the problem using both debugging and tracing methods. Desirable debugging features are the ability to debug multiple processes in a single session, allowing runtime program modification and patching. Beyond interactive debugging, both data and event tracing offer the lightest way to touch a multi-threaded program.

Program Performance
There are many parameters that contribute to overall program performance. On multi-core systems, it's important to sort out the performance issues by application and by thread. In addition, multi-core versions of your software should work faster than a single-core version. Often programmers are stumped when they achieve poor performance on parallel systems. Having the right tools to drill down into the processor and cores is essential if bottlenecks are to be identified.

Load Balance
The most obvious issue with multi-core processors is to make sure all your cores are busy and work is balanced across them. An unbalanced application will result in poor performance improvement because one core (or thread) has become the slow step in the process. For this reason, it's important to know "what's running where?" and "how resources are being used" to eliminate bottlenecks and ensure optimum performance.

Besides load balance, there are other parameters that can indicate how well a core is performing. Monitoring imbalances in parameters like context switches, interrupts, memory paging, and processor affinity can also indicate poor performance.

A Linux performance tuning utility can aid significantly in system and application tuning. It's ideally suited for multi-core application analysis because it allows the user to probe by process and thread while observing key system metrics that can influence performance. Information can be displayed for individual processor cores so that the real-time load balance can be observed while the application is running.

Viewing Performance
A program running on single-core processors can be viewed as a progression of events dictated by the programmer. Fleshing out performance issues often requires programmers to look at the events in detail. Multi-threaded codes running on multi-core environments often have deeper issues that could not exist on single-core processors. These deep issues often involve timing between threads and the resources they touch. One way to go deep into program behavior is to instrument a program so that detailed performance data can be harvested. In preserving exact runtime behavior, user-written instrumentation can be difficult and introduce further issues in the code (or hide issues as well). It's often best to use a tracing library that's been specifically designed for this purpose.

During program operation, an instrumented program should emit trace data that's collected with minimal influence on the running program. After the program finishes, a trace file that contains the runtime information will provide insights into program and thread behavior. Another important area that is often neglected in program tracing is the operating system. Often serious bottlenecks can be traced to certain tunable aspects of the Linux kernel and thus are hidden from the end user.

Trace files can produce extremely large amounts of information when multiple cores are involved. So is it important to use a tool that can sort through the trace information easily so that critical points can be identified.

As previously mentioned, a Linux trace utility that's aware of both user application and kernel-level activity can provide a level of information not obtainable with ordinary debuggers. This information can also be used to enhance the performance of the application. Users generally know the critical parts of their programs and the trace tool can provide a detailed window into these areas. A well designed GUI front-end can also provide easy navigation through the trace data.

Recommendations
When developing multi-core code, the following recommendations will assist in faster and better code generation.

1)  Create a reference sequential program that can be used as a baseline for both results and performance.
2)  Use your reference program as a basis for your threaded program and make the number of threads tunable so that your program can be easily collapsed to one thread.
3)  Use a real-time debugger that preserves the timing of your program. Additional tools beyond debuggers that provide data and event tracing may be needed to ferret out difficult issues.
4)  Once the application is running correctly, examine the load and resource use by using a system/application tuner and event analyzer.
5)  As a final step, check your assumptions. The current x86 64-bit architectures all run the same binary codes, but have widely varied hardware implementations. Some time invested analyzing your program with regard to these areas will be well spent.

Conclusion
The speed increase offered by multi-core designs has become an exciting part of software creation. When writing and debugging code for multi-core systems, however, attention must be paid to new issues that weren't present before. Lock and race conditions can be particularly difficult to resolve with tools designed for single processors. Furthermore, improved performance isn't always guaranteed and may require deeper analysis of runtime behavior than was needed in the past.

Finally, it can't be stressed enough that as hard as single-processor programming can be, multi-core can be much more difficult. A good set of tools is essential to controlling costs and achieving delivery schedules.

References
The following sources can be consulted for general information about multi-core hardware and software. The Internet is a good source of additional information as well.

  • Concurrent Computer Corporation. "Preparing for the Revolution, Maximizing Dual-Core Technology."
    www.ccur.com.
  • Philippe Paquet. "Debugging Concurrency." www.gamasutra.com/features/20050606/paquet_pfv.htm.
  • Herb Sutter and James Larus. "Software and the Concurrency Revolution." Microsoft ACM Queue vol. 3, no. 7. September 2005.

More Stories By Douglas Eadline

Dr. Douglas Eadline has over 25 years of experience in high-performance computing. You can contact him through Basement Supercomputing (http://basement-supercomputing.com).

More Stories By Vince Hauber

Vince Hauber, a senior product manager with Concurrent Computer Corporation, has over 40 years experience in system software and platform solutions. Concurrent is a leading provider of real-time Linux distributions and tools.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
We build IoT infrastructure products - when you have to integrate different devices, different systems and cloud you have to build an application to do that but we eliminate the need to build an application. Our products can integrate any device, any system, any cloud regardless of protocol," explained Peter Jung, Chief Product Officer at Pulzze Systems, in this SYS-CON.tv interview at @ThingsExpo, held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA
SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara California. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infras...
SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
SYS-CON Events announced today that GrapeUp, the leading provider of rapid product development at the speed of business, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company, specialized in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market acr...
SYS-CON Events announced today that Enzu will exhibit at SYS-CON's 21st Int\ernational Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Enzu’s mission is to be the leading provider of enterprise cloud solutions worldwide. Enzu enables online businesses to use its IT infrastructure to their competitive advantage. By offering a suite of proven hosting and management services, Enzu wants companies to focus on the core of their ...
New competitors, disruptive technologies, and growing expectations are pushing every business to both adopt and deliver new digital services. This ‘Digital Transformation’ demands rapid delivery and continuous iteration of new competitive services via multiple channels, which in turn demands new service delivery techniques – including DevOps. In this power panel at @DevOpsSummit 20th Cloud Expo, moderated by DevOps Conference Co-Chair Andi Mann, panelists examined how DevOps helps to meet the de...
SYS-CON Events announced today that Cloud Academy named "Bronze Sponsor" of 21st International Cloud Expo which will take place October 31 - November 2, 2017 at the Santa Clara Convention Center in Santa Clara, CA. Cloud Academy is the industry’s most innovative, vendor-neutral cloud technology training platform. Cloud Academy provides continuous learning solutions for individuals and enterprise teams for Amazon Web Services, Microsoft Azure, Google Cloud Platform, and the most popular cloud com...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
SYS-CON Events announced today that CA Technologies has been named "Platinum Sponsor" of SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CA Technologies helps customers succeed in a future where every business - from apparel to energy - is being rewritten by software. From planning to development to management to security, CA creates software that fuels transformation for companies in the applic...
Multiple data types are pouring into IoT deployments. Data is coming in small packages as well as enormous files and data streams of many sizes. Widespread use of mobile devices adds to the total. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, panelists looked at the tools and environments that are being put to use in IoT deployments, as well as the team skills a modern enterprise IT shop needs to keep things running, get a handle on all this data, and deliver...
In his session at @ThingsExpo, Eric Lachapelle, CEO of the Professional Evaluation and Certification Board (PECB), provided an overview of various initiatives to certify the security of connected devices and future trends in ensuring public trust of IoT. Eric Lachapelle is the Chief Executive Officer of the Professional Evaluation and Certification Board (PECB), an international certification body. His role is to help companies and individuals to achieve professional, accredited and worldwide re...
Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...
No hype cycles or predictions of zillions of things here. IoT is big. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, Associate Partner at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He discussed the evaluation of communication standards and IoT messaging protocols, data analytics considerations, edge-to-cloud tec...
"When we talk about cloud without compromise what we're talking about is that when people think about 'I need the flexibility of the cloud' - it's the ability to create applications and run them in a cloud environment that's far more flexible,” explained Matthew Finnie, CTO of Interoute, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
With the introduction of IoT and Smart Living in every aspect of our lives, one question has become relevant: What are the security implications? To answer this, first we have to look and explore the security models of the technologies that IoT is founded upon. In his session at @ThingsExpo, Nevi Kaja, a Research Engineer at Ford Motor Company, discussed some of the security challenges of the IoT infrastructure and related how these aspects impact Smart Living. The material was delivered interac...
The Internet giants are fully embracing AI. All the services they offer to their customers are aimed at drawing a map of the world with the data they get. The AIs from these companies are used to build disruptive approaches that cannot be used by established enterprises, which are threatened by these disruptions. However, most leaders underestimate the effect this will have on their businesses. In his session at 21st Cloud Expo, Rene Buest, Director Market Research & Technology Evangelism at Ara...