Download presentation
Presentation is loading. Please wait.
1
A .NET Language for Safe and Scalable Concurrency
VTL02 Axum A .NET Language for Safe and Scalable Concurrency Niklas Gustafsson Software Architect Parallel Computing Platform
2
The Parallel Glass Ceiling
Practices not sustainable Complexity Performance Scalability Switching to new models Will require rethink: programmers + platform vendors Will take time Strong tool support needed to rein in costs
3
Shared Memory Sharing Basic model: Threads / tasks
Common address space Exchange data in memory cells Synchronize via CAS in memory cells Take locks to protect data
4
Unpartitioned State A Huge Mess Performance
Unstated, indirect, subtle data dependencies Documentation quickly out of sync with reality Requires enormous discipline Process scale Performance Overlapping working sets + false sharing Cache coherence traffic will dominate Technology scale
5
Shared Memory Implicit component dependencies 0x0001a3f0:
6
Shared Memory As core count grows…
7
Shared Memory … we have to add components
8
Shared Memory … and more…
9
Shared Memory … and more…
10
Shared Memory … and more…
11
Shared Memory … until all we see is a tangled mess…
12
Shared Memory … and how it’s going to hurt us…
13
Shared Memory … unless, of course, we’re blissfully unaware
14
Shared Memory However, the reality is likely this…
15
Shared Memory … so we document it…
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Lorem ipsum dolor sit amet, Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum..
16
Shared Memory … but a bug is fixed…
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur? Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Lorem ipsum dolor sit amet, Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum..
17
The Answer? We all know of a system that…
… runs on millions and millions of processors … is programmed by hundreds of thousands of developers in thousands of organizations often competing with each other … is known to scale … is remarkably robust … may have something to teach us
18
The Web Loosely coupled Low trust between “components”
Partitioned state Message-passing (HTTP Get/Put)
19
Partitioned State Firm boundaries, explicit dependencies
20
Message-Passing Data exchange Synchronization
Information passed via messages Data is sent by: Copy Reference to immutable data (in-process) Ownership transfer (in-process) Synchronization Data exchange ≡ synchronization
21
Asynchrony Data exchange needs to be asynchronous
Removes inter-component dependencies in time Frees up components to do work in parallel Requires new ways of designing programs IAsyncResult Continuation-passing, e.g. CCR Promises Data-flow networks Events
22
Language Support New practices require new languages
Libraries good at enabling, not constraining users Formalism of state partitioning Asynchrony
23
Axum Special-purpose language in incubation Partition data into domains Agents use shared state within domains Agents use message-passing between domains Support for asynchrony and data-flow
24
Axum Concepts Agent Domain Channel Schema
25
Channels Conduit for messages between two agents
Support for in-process and distributed messaging Define ports as communication vocabulary channel PingPong { input bool Ping; output Signal Pong; } Input port ‘Ping,’ sending data from a client to an agent Output port ‘Pong,’ sending data from an agent to its client
26
Agents Active components, similar to threads but has limited access to shared mutable state Send and receive messages via channels agent PingAgent : channel PingPong { public PingAgent () while (receive(Ping)) Pong <-- Signal.Value; }
27
Connecting to an Agent Connections are made in one of two ways:
var tble = provider.Connect<TableAccess>(“ var tble = Table.TableAgent.CreateInNewDomain(); A factory for channels A channel type An agent address An agent type A factory method for in-process agents
28
Ping Pong channel PingPong { input bool Ping; output Signal Pong; }
agent PingAgent : channel PingPong public PingAgent() while (receive(Ping)) Pong <-- Signal.Value; agent MainAgent : channel Microsoft.Axum.Application { public MainAgent() var pp = PingAgent.CreateInNewDomain(); for (int i = 0; i < 100; i++) pp::Ping <-- true; receive(pp::Pong); } pp::Ping <-- false; Done <-- Signal.Value;
29
Domains Define state shared by several agent instances
Isolate agents in different domains from each other Foundation for seamless distribution of agents Agents are “hosted” within domains domain Table { Dictionary<string, string> dict = new Dictionary<string,string>(); public Table() Host<TableAgent>(“TableAgentAddress"); } public agent TableAgent : channel TableAccess ...
30
Domains + Agents = ♥ ♥ ♥ Agents declared as
Writer – allowed to modify state Reader – allowed to read mutable state N/A – no access to mutable state Agent code is scheduled in parallel based on classification Agents in different domains run in parallel “One writer, many readers” within each domain No-access agents run completely in parallel
31
Schema Payload definition Guaranteed to serialize
Efficient in-process copying schema TableEntry { required String Key; required String Value; rules { require !String.IsNullOrEmpty(Key); require !String.IsNullOrEmpty(Value); } }
32
Protocols Define legal order of messages
Place constraints on payload values channel TableAccess { input KeyValuePair <String,String> Put; input String Get : String; input Signal Done; Start: { Put $ (!String.IsNullOrEmpty(value.Key)) -> Start; Get $ (!String.IsNullOrEmpty(value)) -> Start; Done -> End; } }
33
Dataflow Networks Propagate data between Operators Operands
Computations (methods) Buffers Channel ports Operators forward, forward once, broadcast, alternate, multiplex, join Operands buffer, single-assignment, transforms, sinks chan::Request ==> TranformString ==> chan::Reply; buffer -<< { TransformString ==> sink, PrintString };
34
Ping Pong agent PingAgent : channel PingPong { public PingAgent()
Ping ==> (b => Signal.Value) ==> Pong; }
35
Ping Pong agent PingAgent : channel PingPong { public PingAgent()
Ping ==> Trace ==> Pong; } private Signal Trace(bool inpt) Console.WriteLine("{0}",inpt); return Signal.Value;
36
Asynchrony Blocking a thread is costly
1MB (or more) stack space Thread context Context switching via ‘syscall’ Asynchronous APIs (APM, EAP, CCR, etc.) Runtime efficient, state in heap Complex to use in program code Axum: let the compiler do the work!
37
Other Languages with Agents
Functional Mostly pure message-passing Dedicated virtual machine Isolation through immutability Transparent support for distribution Support for asynchrony (receive) Scala Runs on JVM No isolation, but some immutable types Distribution a separate model Basic support for asynchrony (react) F# Functional Runs on .NET No isolation, but some immutable types Distribution a separate model Support for asynchrony (async + let!)
38
F# and Axum Axum model a closer fit with F# than C++/C#
Immutable collection types Support for asynchrony In-process agent API available Add channels, isolation, schema and you have Axum Check out Luke Hoban’s F# session next
39
Summary Shared Memory Pure Message Passing Axum
Complexity hard to rein in Performance suffers as cache coherence dominates memory system Pure Message Passing Separation of components High overhead Does not leverage existing know-how Axum Balances shared memory and message-passing Reduce complexity Leverage existing patterns and libraries
40
Try it out! http://msdn.microsoft.com/devlabs
41
Parallel Computing at PDC09
Overview FT07: The State of Parallel Programming WKSP08: Patterns of Parallel Programming Managed code in Visual Studio 2010 FT03: Manycore and .NET 4: A Match Made in Visual Studio 2010 FT21: PLINQ: LINQ, but Faster! FT20: F# for Parallel and Asynchronous Programming Native code in Visual Studio 2010 SVR18: Developing Applications for Scale-Up Servers Running Windows Server 2008 R2 SVR10: Lighting up Windows Server 2008 R2 Using the ConcRT on UMS FT19: C++ Forever: Interactive Applications in the Age of Manycore HPC Server SVR01: Accelerating Applications Using Windows HPC Server 2008 Research and Incubation VTL02: Axum: A .NET Language for Safe and Scalable Concurrency VTL32: Concurrency Fuzzing & Data Races SVR17: Data-Intensive Computing on Windows HPC Server with DryadLINQ VTL04: Rx: Reactive Extensions for .NET FT36: Future of Garbage Collection
42
YOUR FEEDBACK IS IMPORTANT TO US!
Please fill out session evaluation forms online at MicrosoftPDC.com
43
channel9.msdn.com/learn
11/18/ :23 AM Learn More On Channel 9 Expand your PDC experience through Channel 9 Explore videos, hands-on labs, sample code and demos through the new Channel 9 training courses channel9.msdn.com/learn Built by Developers for Developers…. © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.