perl 6 concurrency - jonathan worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · the...

147
Perl 6 Concurrency Jonathan Worthington | Edument

Upload: others

Post on 03-Jun-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Perl 6 Concurrency

Jonathan Worthington | Edument

Page 2: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Hi. I'm Jonathan.

Page 3: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Hi. I'm Jonathan.

I do Perl 6 stuff.... Perl 6 concurrency designer

MoarVM founder and architect Rakudo compiler developer

Page 4: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Hi. I'm Jonathan.

I do Perl 6 stuff.... Perl 6 concurrency designer

MoarVM founder and architect Rakudo compiler developer

And I lead the Edument Prague office... Developer tooling and compiler consultancy

Founder of Cro and Comma

Page 5: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Today...

Page 6: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The essence of Perl 6 concurrency Key concepts and mechanisms

Page 7: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The essence of Perl 6 concurrency Key concepts and mechanisms

The application of Perl 6 concurrency A case-study from a production application

Page 8: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The essence of Perl 6 concurrency Key concepts and mechanisms

The application of Perl 6 concurrency A case-study from a production application

The future of Perl 6 concurrency Where are we heading?

Page 9: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The

essence of Perl 6 Concurrency

Page 10: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The essence of Perl 6 concurrency and parallelism reflects the essence of the

Perl language family…

Page 11: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

A Perlish language is

multi-paradigm

Page 12: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Because when we have a range of problem-solving tools, we can choose the most appropriate one for

the problem at hand

Page 13: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Concurrency

Trying to get the right result when we have multiple,

possibly competing, tasks with overlapping start/end times

Page 14: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

We don't choose concurrency.

Concurrency chooses us.

Page 15: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Parallelism

Exploit multi-core hardware to do the same task, and deliver equivalent results, but in less

wallclock time.

Page 16: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Concurrency is part of the

problem domain.

Parallelism is part of the

solution domain.

Page 17: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

With concurrency, correctness

is domain specific.

With parallelism, correctness

is just equivalence.

Page 18: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Concurrency and parallelism are best addressed by

different tools.

Page 19: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

In fact, there's different kinds of

parallelism…

Page 20: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Task parallel

Page 21: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Task parallel

Data parallel

Page 22: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

And different approaches to concurrency…

Page 23: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Concurrent objects

Object

Method calls

Page 24: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Concurrent objects

Event processing

Object

Method calls

Event Processor

Event Event Event

Page 25: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Perl 6 provides for all of these, and more

Page 26: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

A Perlish language makes the

easy things easy

Page 27: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

my ($input-config, $app-config) =

do {

load-yaml slurp $input-file

},

do {

from-json $_ with slurp $*HOME.add('.fooconf')

}

Load and parse two files in parallel

my ($input-config, $app-config) = await

start {

load-yaml slurp $input-file

},

start {

from-json $_ with slurp $*HOME.add('.fooconf')

}

Page 28: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

.say for (1..*) .grep(-> $n { $n.is-prime && $n eq $n.flip }) .head(100);

Parallel search for 100 palindromic primes

.say for (1..*) .hyper(batch => 512, degree => 6) .grep(-> $n { $n.is-prime && $n eq $n.flip }) .head(100);

Page 29: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

class Cache { has %!entries; method add(Str $key, Any $value --> Nil) { %!entries{$key} = $value; } method lookup(Str $key --> Any) { %!entries{$key} // fail "No entry '$key'" } }

Acquire a lock around all method calls

monitor Cache { has %!entries; method add(Str $key, Any $value --> Nil) { %!entries{$key} = $value; } method lookup(Str $key --> Any) { %!entries{$key} // fail "No entry '$key'" } }

Page 30: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Re-run a script whenever it changes

react { my $current-proc; whenever $script.watch.unique(:as(*.path), :expires(1)) { .kill with $current-proc; $current-proc = Proc::Async.new($*EXECUTABLE, $script); my $done = $current-proc.start; whenever $done { $current-proc = Nil; } } }

react { my $current-proc; whenever $script.watch.unique(:as(*.path), :expires(1)) { .kill with $current-proc; $current-proc = Proc::Async.new($*EXECUTABLE, $script); my $done = $current-proc.start; whenever $done { $current-proc = Nil; } } }

react { my $current-proc; whenever $script.watch.unique(:as(*.path), :expires(1)) { .kill with $current-proc; $current-proc = Proc::Async.new($*EXECUTABLE, $script); my $done = $current-proc.start; whenever $done { $current-proc = Nil; } } }

react { my $current-proc; whenever $script.watch.unique(:as(*.path), :expires(1)) { .kill with $current-proc; $current-proc = Proc::Async.new($*EXECUTABLE, $script); my $done = $current-proc.start; whenever $done { $current-proc = Nil; } } }

react { my $current-proc; whenever $script.watch.unique(:as(*.path), :expires(1)) { .kill with $current-proc; $current-proc = Proc::Async.new($*EXECUTABLE, $script); my $done = $current-proc.start; whenever $done { $current-proc = Nil; } } }

Page 31: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

A Perlish language makes the

hard things possible

Page 32: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Perl 6 provides access too…

OS-level threads

Locks Atomic operations

Page 33: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Don't use them!*

Page 34: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Don't use them!*

* Unless you're implementing new concurrency or parallelism paradigms

and data structures in Perl 6

Page 35: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

A Perlish language offers

whip-up-ability

Page 36: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

When we "whip up a solution", we're typically taking existing components, which we then

wire together

Page 37: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

And wiring things together depends on them having a

common interface

Page 38: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Promise A single, asynchronously

produced, value

Supply A stream of asynchronously

produced values

Page 39: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

A Supply can be…

Network packets WebSocket messages

File system notifications Child process output

UI events Timer ticks

Domain events

Page 40: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

A Perlish language will

torture the language implementer for the sake

of the language user

Page 41: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

M : N

Page 42: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

M : N High-level

tasks OS-level threads

Page 43: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

M : N High-level

tasks OS-level threads

Many ~Core-count

Page 44: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

await

Suspend the current high-level task until the

thing it needs is available

Page 45: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

async?

Page 46: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

No async!

No need to refactor all of the callers in order to use await!

Just save the whole stack.

Page 47: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

A Perlish language helps us to

do the right thing

Page 48: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

What does the supply/whenever

syntax give us?

Page 49: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Thanks to using it, this code will work robustly…

Page 50: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Unsubscription, however things end

Page 51: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Unsubscription, however things end

If the data source

completes…

Page 52: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Unsubscription, however things end

If the data source

completes, cancel the timeout

Page 53: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Unsubscription, however things end

If we hit the timeout…

Page 54: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Unsubscription, however things end

If we hit the timeout, close the

data source

Page 55: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic exception propagation

Page 56: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic exception propagation

If the data source

crashes…

Page 57: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic exception propagation

If the data source

crashes, cancel the timeout,

convey the exception

Page 58: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic cleanup upon downstream close

Page 59: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic cleanup upon downstream close

If our consumer

unsubscribes…

Page 60: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic cleanup upon downstream close

If our consumer

unsubscribes, close the data

source and cancel the timeout

Page 61: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic concurrency control

Page 62: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

sub timeout(Supply $source, Real $seconds --> Supply) {

supply {

whenever $source {

emit $_;

LAST done;

}

whenever Promise.in($seconds) {

die X::Timeout.new;

}

}

}

Automatic concurrency control

We'll only ever be in one whenever

block at a time

Page 63: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Even if we remembered all of these, it'd be a huge amount of boilerplate

Instead, we just Do The

Right Thing

Page 64: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The

application of Perl 6 Concurrency

Page 65: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

eAsii

A tool to assist insurance or reinsurance undertakings with

calculation of the European regulatory standard formula (Solvency II, Pillar I)

and associated reporting to the supervisory authority via XBRL

(Solvency II, Pillar III).

Page 66: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

EasiiLang

A pure, functional, non-Turing Complete language

The entire calculation forms a DAG, so can see the path from input to result

Syntax inspired by Perl 6

Page 67: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

EasiiLang was easy...

Parsed by a Perl 6 grammar

Produces a tree, which is walked to evaluate the expression

Perl 6 is good at this stuff. But, that's

not the focus for today...

Page 68: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Architecture Backend

Exposes a HTTP API (using Cro) Versioned Input Storage (uses a SQLite database)

Live Dataset (in-memory reactive calculation)

Page 69: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Architecture Backend

Exposes a HTTP API (using Cro) Versioned Input Storage (uses a SQLite database)

Live Dataset (in-memory reactive calculation)

Frontend JavaScript Application (qooxdoo, transpilation)

View, View Model, Store

Page 70: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Architecture Backend

Exposes a HTTP API (using Cro) Versioned Input Storage (uses a SQLite database)

Live Dataset (in-memory reactive calculation)

Frontend JavaScript Application (qooxdoo, transpilation)

View, View Model, Store

HTTP WebSocket

Page 71: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Cro

Libraries for building distributed systems; currently mostly used for

building HTTP applications

Request and response processing pipeline is a set of steps connected

using Supply asynchronous

Page 72: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Cro has...

WebSocket support

Reactive middleware

Log::Timeline integration, to allow tools to trace the request pipeline

Page 73: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly
Page 74: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

6 requests being served in parallel

Page 75: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly
Page 76: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Drill down into the pipeline

Page 77: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly
Page 78: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

See the cost of each stage

Page 79: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Log::Timeline

Can use it to do application-level logging also

Doing this helped us to understand

the application behavior, and guided our use of parallelism

Page 80: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The model

Developed by mathematicians based on European regulations

Loaded at application startup

During model development, reloaded

when the model is changed

Page 81: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The current model 350+ modules

A YAML file for each. Totals over 100,000 lines of YAML.

Nearly 4,000 formulas 25,000 lines of EasiiLang

between the modules

64 Excel Documents... Based on the legal

requirement of the European supervisory authority

...cached as 7 MB of JSON Since reading from Excel every time we load the

model is too slow

5,500+ lines of CSV Containing parameters, such

as country-specific data

2000+ translation keys And many more to come,

written in .po files

Page 82: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Model loading

As the model grew, model reloads became long enough to be annoying

Page 83: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Can we parallelize?

First, need to consider the data dependencies of model loading

Page 84: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Can we parallelize?

First, need to consider the data dependencies of model loading

The check phase needs layouts, parameters, and

all modules

Page 85: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Can we parallelize?

First, need to consider the data dependencies of model loading

Each module can be parsed and compiled independently...

Page 86: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Can we parallelize?

First, need to consider the data dependencies of model loading

...and without knowing the parameters and layouts.

Page 87: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Data parallelism

When we apply the same operation to many data items

Parallelism comes from partitioning

the data - into items or batches - and spreading them over worker threads

Page 88: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

my @modules = @files

.grep(/ \.(yaml|yml) $/)

.map(-> $file {

my $yaml = Easii::Log::ParseModuleYAML.log: $task, :file(~$file), -> {

self!load-yaml($file, $schema, $problems)

}

with $yaml {

Easii::Log::CompileModule.log: $task, :file(~$file), -> {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

}

});

Module loading

Page 89: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

my @modules = @files

.grep(/ \.(yaml|yml) $/)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

});

Module loading (Log::Timeline use omitted for simplicity)

Page 90: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Load in parallel my @modules = @files

.grep(/ \.(yaml|yml) $/)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

});

my @modules = @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

});

my @modules = @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

});

Page 91: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

But wait... my @modules = @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

});

This problem collector may be used concurrently

Page 92: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Not safe my class Problems {

has @.errors;

method add-error($error--> Nil) {

@!errors.push($error);

}

}

Potential race on this

Page 93: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Make it a monitor

Acquires a lock automatically.

use OO::Monitors;

my monitor Problems {

has @.errors;

method add-error($error--> Nil) {

@!errors.push($error);

}

}

Page 94: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Huge improvement!

Takes 30% of the time it used to

Page 95: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Huge improvement!

Takes 30% of the time it used to

Up to 6 modules loaded in parallel

Page 96: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Task parallelism

Identify different, independent, tasks that we could do in parallel

Have different threads do them

Page 97: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Task parallelism?

There's an opportunity!

Load layouts and parameters in parallel

with the modules

Page 98: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Load asynchronously my @modules = @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

});

my $modules-load = start @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

});

Works lazily!

my $modules-load = start @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file {

my $yaml = self!load-yaml($file, $schema, $problems) ;

with $yaml {

Easii::Model::Module.new(parsed => $yaml,

source => $file.basename)

}

})

.eager;

Page 99: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Load asynchronously my $parameter-load = start self!load-parameters(

$parameters-path, $problems);

my $layout-load = start self!load-layouts(

$layouts-dir, $cache-dir, $problems);

Page 100: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Load asynchronously self.bless:

modules => await($modules-load),

parameters => await($parameter-load),

layouts => await($layout-load),

dpm => self!load-dpm($dpm-dir, $cache-dir),

load-errors => $problems.errors

Page 101: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

An improvement?

A little, though not that much more, due to resource contention

Page 102: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Looking closer...

Page 103: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Looking closer...

Huge module that takes ages to parse

Page 104: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Looking closer...

Compilation of that module (quite quick)

Page 105: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Looking closer...

Only stuff for one CPU core to do

Page 106: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Do the big files first

my $modules-load = start @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file { ... })

.eager;

my $modules-load = start @files

.grep(/ \.(yaml|yml) $/)

.race(batch => 1, degree => 6)

.map(-> $file { ... })

.eager;

my $modules-load = start @files

.grep(/ \.(yaml|yml) $/)

.sort(-*.s)

.race(batch => 1, degree => 6)

.map(-> $file { ... })

.eager;

Page 107: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

It helps!

Model loading in around 20% of the original time - with few code changes!

Page 108: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Concurrency too

Parallelism gave us an easy speedup

However, implementing eAsii was also greatly aided by Perl 6's concurrency support - of note, for live calculations

Page 109: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Datasets

A set of inputs, either entered manually, uploaded, or sometimes

derived from other inputs

Current test customer dataset has 250,000 inputs (and each input has a change history, for audit purposes)

Page 110: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Processing inputs Sync call Supply

Page 111: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Processing inputs

Cro route handler HTTP POST

Sync call Supply

Page 112: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Processing inputs

Cro route handler HTTP POST DB

1. Write to database

Sync call Supply

Page 113: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Processing inputs

Cro route handler HTTP POST DB

1. Write to database Change! 2. Emit an event

Async

Propagation Queue

Sync call Supply

Page 114: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Processing inputs

Cro route handler HTTP POST DB

1. Write to database Change! 2. Emit an event

Async

Propagation Queue

Live Dataset

Changes!

Sync call Supply

Page 115: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Processing inputs

Cro route handler HTTP POST DB

1. Write to database Change! 2. Emit an event

Async

Propagation Queue

Live Dataset WebSocket messages

Changes!

Sync call Supply

Cro WebSocket Handler

Page 116: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Processing timeline

HTTP request completes quickly, recalculation runs in the background

Page 117: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Live dataset setup class Easii::LiveDataset {

has Int $.dataset is required;

has Supply $.input-source is required;

has Supplier $.changes .= new;

}

Page 118: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Live dataset setup class Easii::LiveDataset {

has Int $.dataset is required;

has Supply $.input-source is required;

has Supplier $!changes .= new;

submethod TWEAK(:%initial-inputs) {

start react {

my $matching-input = $!input-source

.grep(*.dataset == $!dataset);

whenever $matching-input {

# Perform reclculation...

}

}

}

}

Page 119: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

if %formula-changes {

$!version++;

$!changes.emit: Easii::LiveDataset::Change.new:

:$!version, :$module-key, :%formula-changes;

}

Live dataset changes

If there recalculation determines there are changes to a module, emit

an event containing them

Page 120: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

WebSocket get -> LoggedIn $user, 'easii', 'setupWebsocket', Int :$dataset {

}

Page 121: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

WebSocket get -> LoggedIn $user, 'easii', 'setupWebsocket', Int :$dataset {

$app.with-current: $user.customer, -> $state {

}

}

Page 122: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

WebSocket get -> LoggedIn $user, 'easii', 'setupWebsocket', Int :$dataset {

$app.with-current: $user.customer, -> $state {

web-socket :json, -> $incoming {

supply {

}

}

}

}

Page 123: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

WebSocket get -> LoggedIn $user, 'easii', 'setupWebsocket', Int :$dataset {

$app.with-current: $user.customer, -> $state {

web-socket :json, -> $incoming {

supply {

my $live-dataset = $state.get-live-dataset($dataset);

whenever $live-dataset.changes -> $change {

}

}

}

}

}

Page 124: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

WebSocket get -> LoggedIn $user, 'easii', 'setupWebsocket', Int :$dataset {

$app.with-current: $user.customer, -> $state {

web-socket :json, -> $incoming {

supply {

my $live-dataset = $state.get-live-dataset($dataset);

whenever $live-dataset.changes -> $change {

my $change-set = $change.for-json;

emit $change-set;

}

}

}

}

}

Page 125: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

We also...

Data-parallelize formula calculation in modules with many instances

Use a Channel to send code to the

live dataset for evaluation, the concurrency control meaning we don't

evaluate it when recalculating

Page 126: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Perl 6: good choice

Perl 6's concurrency features helped us to deliver on the reactive aspects of

the application

Meanwhile, the parallelism gave us a bunch of easy performance gains

Page 127: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Lesson: tools are good

Tooling to visualize what's going on in a concurrent/parallel system is a huge win

Page 128: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

The

future of Perl 6 Concurrency

Page 129: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

We have a good story - but something is missing

Something, perhaps, that will turn out to be a differentiator

Page 130: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Safety

Page 131: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

There's smart folks who feel the future is static proofs

There's others who argue to

bind as late as possible

Page 132: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

"We need to write tests to assert correctness anyway"

"It's easier to debug a

concrete situation than a theoretical type error"

Page 133: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

But what if the failure is a data race that happens

1 time in 10,000?

Page 134: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

What we kind of need is...

Page 135: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

What we kind of need is...

….ummm….

Page 136: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

What we kind of need is...

….ummm….

reliable failure!

Page 137: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

We need a Perl-ish solution.

That's a research problem.

But it's one I believe we should take on.

Page 138: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Why?

Page 139: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

So we can make getting the easy things right easier

Page 140: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

So we can make getting the hard things right possibler

Page 141: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

So we can make the whipped up concurrent or parallel

program do the right thing

Page 142: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Because we torment the language implementer for the

sake of the language user

Page 143: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

These are the things that define a Perlish language

Page 144: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

These are the things that define a Perlish library

Page 145: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Being easy to get in to

Whipping up ideas together

Trying to do the right thing

Realizing others are trying to do the right thing

Page 146: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

That, to me, seems like a way to be a Perl community

Page 147: Perl 6 Concurrency - Jonathan Worthingtonjnthn.net/papers/2019-perlcon-concurrency.pdf · The current model 350+ modules A YAML file for each. Totals over 100,000 lines of YAML. Nearly

Thank you!

@ [email protected]

W jnthn.net

jnthnwrthngtn

jnthn

cro.services

commaide.com