Translation: Parallel computing for Microsoft style

Source: Internet
Author: User
Tags microsoft website

Parallel Microsoft-style

by Andrew Binstock, July 20, 2011

Note: Mainly automatic translation, I made a small amount of modification

1 Comment

The Actor model of concurrency is gaining favor in Java and remains largely ignored by Microsoft
The Actor model has been heavily used in Java, and Microsoft has ignored him a lot.

One area in which Microsoft operating systems has a long been on the vanguard is multithreading APIs. Even before multicore processors were the norm, Microsoft offered expansive APIs for managing threads and Thread-like exec Ution streams called fibers. The Win32 platform had a wide selection of thread-management functions that could being used with considerable ease. While I can ' t speak for every operating system, that collection of APIs is considerably greater and more sophisticated th An UNIX or Linux counterparts. Pthreads, the Now-standard threading implementation on Linux, is a much smaller solution. However, Pthreads does provide a benefit singularly lacking in the Windows implementation:portability. Pthreads originated on UNIX where it still runs on the various variants. A good port on Win32 exists, in addition to the multiple Linux distributions.

One area where Microsoft's operating system has long been a leader is the multithreaded API. Even before a multi-core processor, Microsoft provided a wide range of APIs to manage thread and thread execution flows, called fiber optics. The WIN32 platform has many thread management features that can be easily used. Although I can't speak for every operating system, the set of APIs is considerably larger and more complex than UNIX or Linux. Pthreads is now the standard thread implementation on Linux and is a much smaller solution. However, Pthreads provides a unique advantage that is missing in the Windows implementation: portability. Pthreads originates from UNIX, it still runs in various variants. In addition to multiple Linux distributions, there is a good port on the Win32.

The Microsoft APIs, however, be very much drawn from the traditional approach to threading, which is a complex model of C Reating threads, managing them individually, and using mutual exclusion to prevent them from interfering with each other. Even though Microsoft ' s Visual Studio IDE have decent support for working with threads, developers can expect to spend a lo T of time in the debugger. In this shared-memory model, the great debugging challenges is replicating the problem, and once it ' s replicated, Dia Gnosing it.

However, the Microsoft API sucks traditional threading methods and threads are a complex model that creates threads, manages them separately, and uses mutexes to prevent them from interfering with each other. Even if Microsoft's visual Studio IDE supports threading, developers can expect to spend a lot of time in the debugger. In this shared memory model, two of the great debugging challenges are repeating problems, and once repeated, diagnose it.

The issue of replication have driven more than one developer to the brink of insanity, if not pushed him over the edge Enti Rely. Some errors show up if certain threads interact in a rare the, with each one handling a specific of data. This might show up as a defect report indicating so, occasionally, transactions aren ' t logged correctly to the database. Trying to recreate what conditions might leads to a event transiently not occurring-when Dozens of threads is in Vario US states of Operation-can is exceedingly difficult, if not impossible. But even if the situation can is faithfully reproduced, trapping the condition and determining how the threads is Crossin G Each of the other incorrectly is arduous. In sum, the shared-memory model is no one's idea of programming fun. And as a result, much software that should has been parallelized long ago runs serially because the job is constantly def Erred until parallelization is the onlyThe gain the needed performance.

The problem with replication has forced more than one developer to get into the brink of insanity if not pushed him completely away. Some errors are displayed only when some threads interact in rare ways, with each thread processing a particular piece of data. This may appear as a bug report, indicating that transactions are occasionally incorrectly logged to the database. Trying to recreate what conditions may cause the event to temporarily not occur-when dozens of threads are in various operational states-can be very difficult, if not impossible. However, even if the situation can be faithfully reproduced, capturing the conditions and determining how the threads are crossed incorrectly is daunting. In short, the shared memory model is the idea of no one's programming fun. As a result, many software that should already be parallelized runs continuously because the job is being postponed until parallelization is the only way to achieve the desired performance.

Various attempts has been made to remove this complexity and thereby facilitate parallel development. One of the strongest pushes have come from Intel, which spearheaded OpenMP a decade ago. OpenMP sought to add keywords to the C (via Pragmas) and Fortran, so this portions of existing programs could be Paralleli Zed. This approach, while limited to only sections of the program, worked well. It was grasp and it cleverly handled the messy thread-management issues behind the scenes. If the code ran correctly on a single thread, chances were excellent that it would still run correctly when parallelized W ith OpenMP keywords. Microsoft's support of the OpenMP made it a natural choice for many applications.

Various attempts have been made to eliminate this complexity and thus contribute to parallel development. One of the strongest drivers came from Intel, which was the first to push OpenMP a decade ago. OpenMP attempts to add keywords to C (through compilation instructions) and Fortran so that part of an existing program can be parallelized. Although this approach is limited to part of the program, it works well. It's easy to master, and it skillfully handles the behind-the-scenes thread management issues. If the code runs correctly on a single thread, the chances of running correctly when you parallelize the OpenMP keyword are very good. Microsoft's support for OpenMP makes it a natural choice for many applications.

More recently, Intel have come out with a more elaborate solution, Cilk Plus, which follows the OpenMP model and leverages Intel's deep knowledge of threading (acquired from a decade of investment in threading tools). James Reinders of Intel provided an excellent technical overview of the problem and solution as viewed from within the IND Ustry in a recent blog post.

Java and the Actor alternative

Interestingly, the languages on the JVM is heading towards a different kind of solution, namely actors. If you ' re not familiar with actors, it's easiest to think of them as functions to which discrete tasks can is sent for EXE Cution. The most common operational metaphor was a thread that had an incoming mailbox to which messages was sent by other actors. The actor processes these messages (which can include tasks to execute or data to operate on) and the output are sent to an Other actors for downstream work.

Interestingly, the language on the JVM is moving towards a different solution, actor. If you are unfamiliar with actors, it is easiest to think of them as functions that discrete tasks can send to execute. The most common manipulation metaphor is the thread that has an incoming mailbox that other participants send messages to. The actor processes these messages (which can include the task to be performed or the data to be manipulated), and the output is sent to another actor for downstream work.

Actors avoid the dangers of the shared-memory model because they touch only the data that's sent to them in messages. If They need some external data, they request it from other actors (by sending the request in the form of a message). In addition, the data actors receive is immutable. They don ' t change the data, rather they copy it and transform the copy. In this, no, threads is ever contending for access to the same data item, nor is their internal operations Interf Ering with one another. As a result, the nightmares I described earlier disappear almost completely.

Actors avoid the risk of sharing the memory model because they touch only the data that is sent to them in the message. If they need some external data, they request it to other participants (by sending the request as a message). Additionally, the data actors receive is immutable. Instead of changing the data, they copy and convert the copy. This way, no two threads compete to access the same data item, and their internal operations do not interfere with each other. As a result, the nightmare I described earlier almost completely disappears.

The actor model has been used in applications this naturally align with message passing:telephone switches, WEB servers, and the like. Increasingly, however, JVM languages is using them for run-of-the-mill applications. Obviously, actors require a different kind of architecture (in the most actor applications, everything are done by actors-mix Ed-model applications is generally not favored.). And in the support of this, they is finding support in several recent languages. For example, Scala and Fantom has built In-actor libraries (Scala's enjoys native syntactic support). Groovy has a widely used actor library. And actor frameworks, such as Akka and Killim, that can is used by any JVM language has recently come to the market.

The actor model has been used in applications that are naturally aligned with messaging: telephone switches, Web servers, and so on. However, more and more JVM languages are being used to run applications. Obviously, actors need different architectures (in most actor applications, everything is done by actors – mixed-model applications are often unpopular.) To support this, they are looking for support in several recent languages. For example, Scala and Fantom build a in-actor library (Scala prefers local syntax support). Groovy has a widely used actor library. And the actors framework that can be used by any JVM language, such as Akka and Killim, has recently been listed.

For all the extensive threading APIs of Microsoft offers, the company have not substantially embraced actors. A good start was made in, and the Redmond giant released asynchronous Agents Library, but it's only a partial acto R implementation and it runs only in C + +. (note:a highly portable, widely used C + + library with actor Building Blocks-but no actor framework-is the ACE library .)

Microsoft has released a pair of packages that contain many actor primitives. These packages, named the Concurrency and Coordination Runtime (CCR) and the decentralized software Services (DSS), were R Eleased in + as part of the Microsoft Robotics Toolkit, curiously enough. The packages has languished there ever since and is not part of the. NET Framework. However, some posts on Microsoft's website suggest, at some a future point, the packages would be migrated to. NET. The timing is left ambiguous and it's not clear whether the APIs would be changed in the migration, nor whether a full acto The R framework is constructed from them.

Another concern about CCR and DSS are that they has not been updated for more than a year, although in the forums, a Proje CT leads from Microsoft refers in several points to an "upcoming" announcement.

In either case, there was no long history of working with this technology-nor any evidence that I can find of any other s Upport for actors in the. NET languages. Microsoft is still primarily oriented towards the traditional models of parallel programming. The benefit of this approach is raw performance. For the same reasons, Intel's libraries target only C, C + +, and Fortran-three languages that is associated with HIGH-SP Eed computation and frequently run as native code.

Application developers who is willing to trade a little performance for ease in writing parallel applications is likely To find Java's embrace of actors an appealing solution (although Java certainly have the traditional primitives for develop ERs want to follow that path.)

I expect that over time, Microsoft would increase its support for the actor programming model. If it comes, the support would likely not being fully embraced by Redmond until pressure in large-scale actor models is a Pplied either by it customers or competition in the market place. In the latter case, the pressure is exerted primarily by jvm-based solutions.

For all the broad threading APIs Microsoft has to offer, the company is not fully accepting actors. It was a good start in 2010 when the Redmond giant released an asynchronous proxy library, but it was just a partial actor implementation that only runs in C + +. (Note: Highly portable, widely used library of C + +, including actor building blocks, but no actor framework-is the ACE library.) )

Microsoft has released a pair of packages that contain many actor primitives. These packages are named concurrency and Coordination Runtime (CCR) and decentralized software services (DSS), which were released as part of the Microsoft Robotics Toolkit in 2008, oddly. The package has been working hard since then, and it's not. NET Framework is part of the. However, some posts on the Microsoft website indicate that, at some point in the future, these packages will be migrated to. NET. Time is unclear, and it is unclear whether the API will change in the migration or build a complete actor framework from there.

Another problem with CCR and DSS is that they haven't been updated for more than a year, although in the Forum, a Microsoft Project mentions "upcoming" announcements from several points.

In either case, there is no long history of using this technology-nor is there any evidence that I can find any other support. NET language of the actor. Microsoft is still primarily oriented towards the traditional parallel programming model. The benefit of this approach is raw performance. For the same reason, Intel's library locates only three languages that are related to high-speed computing, C,c + + and fortran--, and is often run as local code.

Application developers are willing to trade a little bit of performance for writing parallel applications and may find Java embracing an attractive solution (although Java certainly has a traditional primitive as the path the developer wants to follow).

I expect that as time goes on, Microsoft will increase support for the actor programming model. But if it comes, support will most likely not be fully embraced by Redmond until the pressure of a large actor model is applied by its customers or the market. In the latter case, the pressure will be primarily imposed by a JVM-based solution.

-andrew Binstock
Editor in chief
[Email protected]
Twitter:platypusguy

Translation: Parallel computing for Microsoft style

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.