1 / 26

Axum

Axum. Better concurrency with a .NET language for isolation and asynchrony. Axum == Maestro. “What's in a name? That which we call a rose By any other name would smell as sweet." Shakespeare, Romeo and Juliet (II, ii, 1-2). Incubation Project. Farther along than research

ganesa
Download Presentation

Axum

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Axum Better concurrency with a .NET language for isolation and asynchrony

  2. Axum == Maestro “What's in a name? That which we call a rose By any other name would smell as sweet." Shakespeare, Romeo and Juliet (II, ii, 1-2)

  3. Incubation Project • Farther along than research • But not yet in productization phase • Have released internally in Microsoft • Will soon release a public beta

  4. Inspirational Quotes “If the state of your entire universe can change from one instant to the next, there’s something wrong with your universe.” “Programmers are asked to take a wildly non-deterministic model and rein it in where needed. We should start with a deterministic model and add non-determinism where necessary.”Ed Lee, UCB

  5. Axum Language • Imperative, managed language • Looks and feels like C# or C++ • Has curly-brace! • And a few other familiar concepts … • Works with all .Net libraries • Such as BCL • Can be mixed with C# or VB.Net • Even in the same project! • Built on top of CCR

  6. Why Another Language? • Relying on programmer’s discipline doesn’t work • Library solutions can only do so much • We want strong safety enforced by the compiler • Reduce complexity • Concurrent by default • “Forget” you’re writing a parallel program • Not intended to substitute other languages • High level orchestration in Axum • Most of the application still written in traditional language

  7. Isolation • Shared state is evil • Processes in OS • Tabs and plug-ins in Google Chrome • Computers on the Web • But: worms, viruses and trojans (when isolation breaks down)

  8. Main Concepts • Domains • Passive containers of state • Agents • Active components; can send messages and share state within the same domain • Channels and Ports • “Pipes” that conduct messages • A channel has a collection of ports

  9. Example: Tax Calculator public channel TaxCalculator { input int Income; output int Tax; } public agent TaxAgent : channel TaxCalculator { public TaxAgent() { var income = receive(this.PrimaryChannel::Income); var tax = (int)(income * GetTaxRate()); this.PrimaryChannel::Tax <-- tax; } }

  10. Example: Tax Calculator, 2 TaxService.TaxCalculatortaxCalculator = new TaxService.TaxCalculator("TaxCalc1"); taxCalculator::Income <-- 50000; // Do something useful while the // taxes are being calculated... inttaxAmount = receive(taxCalculator::Tax);

  11. Agents and Channels User Agent Server Agent TaxCalculator Income Tax

  12. Example: Tax Calculator, 3 • Demo: • Simple Input/Output ports • Request-Reply port • Forwarding network

  13. Dataflow Programming • Execution is triggered by the availability of data • Spreadsheet: • Change in a cell triggers reevaluation of dependent cells; • Independent cells can change concurrently • Compiler: • Characters flow through lexer turning into tokens; • Tokens go through grammar turning into AST; • AST goes through several passes

  14. Image Processor • Read JPG, Sharpen,Reduce “red eye” effect, Shrink, Save as 85% quality JPG • Simple pipeline PrimaryChannel::FileName ==> Sharpen ==> RemoveRedEye ==> Shrink ==> Save; Contrast with: Save(Shrink(RemoveRedEye(Sharpen(filename))));

  15. Isolation • No two stages of the pipeline can access the same image! • Let’s dive deeper…

  16. Units Of Isolation in Axum • Domains • Passive containers of shared state • Agents • Disciplined access to domain state • Writer: can write domain state • Reader: can read domain state • No-access: cannot access domain mutable state • True Functions • In agents, cannot modify domain and agent state • In domains, cannot modify domain state

  17. Example domain D { int data; readeragent A : channel C { public A() { int n = data; // OK data = 10; // error! } } function void f() { data = 20; // error } }

  18. Example, cont domain D { int data; const intcdata; agent A : channel C // no-access agent { public A() { int n = data; // error int m = cdata; // OK } } }

  19. Good ‘ol C++ • Const data: const int n=1; • Pointer to const: int const * p = &n; • Rule 1: Cannot modify const data const S* ps; *ps = s; // error (*ps).val = 0;// error ps->val = 10; // ditto • Rule 2: Cannot convert pointer to const to pointer to non-const

  20. The Many Faces of Const struct S { intval; void f() const { val= 1; // Error! // Translates to: // (*this).val = 1; } };

  21. Loophole! struct S { intval; int *ptr; }; … const S * ps = &s; // error: l-value specifies const object: ps->val = 0; *ps->ptr = 1; // OK!

  22. Example domain D { int data; readeragent A : channel C { public A() { int n = parent.data; // OK, parent is readonly parent.data= 10; // error! } } function void f() { this.data = 20; // error, this is readonly } }

  23. Immutability in Axum • Readonly vs. Const • Data cannot be mutated through readonly reference. • Const reference can only refer to immutable data (data that never changes) • Readonly: “I won’t break you” • Const: “You won’t break me” • Deep immutability • a.b.c.d = 1; // error if one of a,b,c,d is readonly

  24. Concurrency in Network • Same model: one writer or multiple readers • Execution scheduled in the most efficient safe way Domain Reader Agent1 Writer Agent2 No Access Agent3 method1 method2 m1 m1 m1 m2 m2 m2 function1 f1 f1 f1 f2 f2 f2 function2

  25. No Silver Bullet… • Non-determinism • Deadlocks • Demo: Dining Philosophers

  26. Thank you! • We need your feedback! • axum@microsoft.com • arturl@microsoft.com • Check out our blog: • http://blogs.msdn.com/maestroteam

More Related