These are chat archives for akkadotnet/akka.net

27th
Apr 2015
Natan Vivo
@nvivo
Apr 27 2015 00:09
@rogeralsing just to get this out of the way, went digging into .net await just to see how it captures the context. as far as I can see, there is no difference between the way LogicalCallContext and SyncrhonizationContext flow between executions, except SyncContext is passed by reference and CallContext is cloned (so there is a little bit overhead there as you noticed), but CallContext always flows while SyncContext is optional. That means you're right in using that, there is no reason to try using a SyncrhonizationContext there.
jcwrequests
@jcwrequests
Apr 27 2015 00:44
I thought everyone might like a distraction from the TPL discussion and might find thus post interesting. http://blogs.technet.com/b/server-cloud/archive/2015/04/08/microsoft-announces-new-container-technologies-for-the-next-generation-cloud.aspx
Natan Vivo
@nvivo
Apr 27 2015 01:47
I found a smell on the actor task scheduler that may account for most problems that are showing, but I'm too tired to investigate today. Boils down to where CallContext is set and restored... I may take a look tomorrow.
Nikita Tsukanov
@kekekeks
Apr 27 2015 05:50
@rogeralsing is #907 related only to TestKit? It might be fixed by a custom SynchronizationContext for tests, I think
At least ASP.NET uses SynchronizationContext for the same thing - to keep ThreadStatic ambient context
Roger Johansson
@rogeralsing
Apr 27 2015 05:52
Yepp, testkit only
However, if i recall correctly, xunit 1.9 has its own synchronizationcontext (?) might be wrong but i think they do
Nikita Tsukanov
@kekekeks
Apr 27 2015 05:58
Hm
Meh, it just wraps original one
Nikita Tsukanov
@kekekeks
Apr 27 2015 06:19
@rogeralsing #912 - something like that
Nikita Tsukanov
@kekekeks
Apr 27 2015 06:28
BTW, what happened with the build server? Don't see any alive agents here
Stefan Sedich
@stefansedich
Apr 27 2015 06:51
After a bad day involving some idiot reversing into my motorbike and causing damage I finally receive my loot for my huge contribution to the CLR (remove a single commented out file).
Microsoft wins the code to loot stakes here.
Roger Johansson
@rogeralsing
Apr 27 2015 07:22
Nice! it's like my contrib to NancyFx, removed 1 line
Stefan Sedich
@stefansedich
Apr 27 2015 07:22
hahaha
Roger Johansson
@rogeralsing
Apr 27 2015 07:22
I created a new team for akka.net repo ... "AsyncAwait" :D so we can cc eachother there
Stefan Sedich
@stefansedich
Apr 27 2015 07:23
so mondays will no longer be like groundhog day?
where I awake to another 1000 line thread about async/await
Roger Johansson
@rogeralsing
Apr 27 2015 07:23
there will be more of them, now that we can metion the entire team ;)
Stefan Sedich
@stefansedich
Apr 27 2015 07:23
teehee
my new mission in life is to collect mugs, so do you need my address @rogeralsing ?
I hope it has the commit # etched into it too
makes it more personal
you could send the mug back each time you do a commit to get it updated.
we call them "mug PRs"
Roger Johansson
@rogeralsing
Apr 27 2015 07:25
oh, we should totally do that :)
Stefan Sedich
@stefansedich
Apr 27 2015 07:39
you can get a dremmel @rogeralsing and personally do each one :D
Arjen Smits
@Danthar
Apr 27 2015 07:57
lol. loving the groundhog day reference ^^
Nikita Tsukanov
@kekekeks
Apr 27 2015 09:54
Is it ok to have a pending PR just to be sure that all tests are still passing on the build server?
Bartosz Sypytkowski
@Horusiath
Apr 27 2015 10:48
I have an idea -> we should create some page for usefull akka code examples - I've found that some of the actor design patterns are to big to be valid as 30 LOC snippets but to small for separate library
Natan Vivo
@nvivo
Apr 27 2015 10:49
@Horusiath - +10 to that
I started a repository sometime ago but only added a stash example. ended up I decided to contribute first to the official docs
But there are 2 things I'd like to do: a page of examples, even basic stuff like stashing - and another of patterns
today, even in jvm akka, patterns are scattered across the internet in blogs. we could try putting the most common together with .net code in the official docs somewhere
Bartosz Sypytkowski
@Horusiath
Apr 27 2015 15:34
I've managed to alter F# API to work on generic versions of ActorRefs - all F# API operates on the messages accepting only specific type of messages in their Tell and Ask operators. So if you'll try to push a message of unhandled type through an F# ActorRef, you'll get a compile-time error
Roger Johansson
@rogeralsing
Apr 27 2015 16:14
nice :)
what about the receiving end? can you still process auto events like Terminated?
Bartosz Sypytkowski
@Horusiath
Apr 27 2015 16:37
This message was deleted
It's possible, but the problem is that F# pattern matching have to work over finite set of types (eg. discriminated unions)
and if you have behavior which work on both Terminated and your custom message types, then probably the closest common type set for them both is object ;)
Bartosz Sypytkowski
@Horusiath
Apr 27 2015 16:43
I'm trying to define an operator <! which could work on typed messages as well as IAutoReceiveMessage instances (since these are system messages)
so even while you have typed actor ref, you still can tell for example PoisonPill to it
Aaron Stannard
@Aaronontheweb
Apr 27 2015 16:48
@kekekeks yep, fine by me to do that
I know I'll get burned by this.. but I don't agree with everything @Aaronontheweb said there
MY WORD IS LAW
THOU SHALT NOT BLASPHEME BEFORE ME
I kid I kid @nvivo
@jwconway got your email about UDP transports - will reply to it today
took some time off the grid to get some rest - I'm spending like 5 hours at the Seattle airport today
so lots of time for email! yay!
Bartosz Sypytkowski
@Horusiath
Apr 27 2015 16:56
.NET type system is so poor, we really deserve for something like Ceylon's type system
Nikita Tsukanov
@kekekeks
Apr 27 2015 17:10
@nvivo @rogeralsing
They've added AsyncLocal<T> in .NET 4.6
Its logic is embedded directly to ExecutionContext
Stephen Cleary's comment on callcontext x synccontext
Natan Vivo
@nvivo
Apr 27 2015 18:14
now that I think about, doesn't make sense to post this here. It appears on the right pane... :-p
Nikita Tsukanov
@kekekeks
Apr 27 2015 18:39
When I've tried to simply replace ThreadStatic with CallContext, examples ran smoothly, but xUnit blew up
Roger Johansson
@rogeralsing
Apr 27 2015 18:55
yes, but maybe it works if we pull in xUnit 2?
there is a PR for that, right?
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:01
Why does it try to serialize ActorCell?
wtf
Roger Johansson
@rogeralsing
Apr 27 2015 19:02
CallContext is copy on write. so you you need to wrap the context in a container, as the copying is shallow
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:07
It still tries to serialize container
using BinaryFormatter
wat
Roger Johansson
@rogeralsing
Apr 27 2015 19:08
CallContext.LogicalSetData("foo", new MyContainer(context)); do you do something like that?
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:09
Yup
And then xUnit tries to serialize it for some reason
After a test is finished
Roger Johansson
@rogeralsing
Apr 27 2015 19:10
oh, thats the reason for the xUnit blow up?
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:10
yup
Nevermind, my skill of working around weird stuff has never failed me before
I got it working
ActorAsyncAwaitSpec failes completely now, but still
Roger Johansson
@rogeralsing
Apr 27 2015 19:11
thats not a good sign :P
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:14
It messes around with CallContext, so no wonder
Gonna try to check that test from #912
Yup, works like a charm
At least CallContext fixes #907
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:19
Any ideas why other stuff might be broken?
Roger Johansson
@rogeralsing
Apr 27 2015 19:20
Nope, in theory it should work just the same, I've tried that too, but never got it to act as it should
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:21
No idea, why TailChoppingSpec also fails
Oh, it uses async Recieve
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:29
It seems that TryExecuteTask discards any CallContext state
and it should do that
but it doesn't restore the old one
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:49
Hm
The task DOES have associated captured context
with that ActorCell inside
Roger Johansson
@rogeralsing
Apr 27 2015 19:53
the last dev to touch that stuff is the one who have to fix it all, thats the rule ;) IM FINALLY FREE!
Natan Vivo
@nvivo
Apr 27 2015 19:53
hahahah
Nikita Tsukanov
@kekekeks
Apr 27 2015 19:55
Stand back, I know regular express how to use dotPeek!
Natan Vivo
@nvivo
Apr 27 2015 20:11
I'm almost creating a blog to post my answer to #907
unfortunately, I don't have a blog...
jcwrequests
@jcwrequests
Apr 27 2015 20:12
@nvivo You can guest post on mine
Natan Vivo
@nvivo
Apr 27 2015 20:12
just kidding. it's just the research is huge
i know how much people love reading these things
jcwrequests
@jcwrequests
Apr 27 2015 20:14
Summaries are easier to read. When I am at work it's like a stock ticker. :) Seriously though you have an open invitation.
@Aaronontheweb Hice Hanselman interview :)
Natan Vivo
@nvivo
Apr 27 2015 20:18
problem is that some things can't be summarized =)
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:20
AsyncMethodBuilder resets context after resuming from await
wat
I'm starting to get it
Natan Vivo
@nvivo
Apr 27 2015 20:22
tasty!
Roger Johansson
@rogeralsing
Apr 27 2015 20:23
@kekekeks resets as in "clears" or resets as in "revert back to the previous one" ?
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:28
Reverts to some clean state
It seems that clean state was somehow set in StartNew
but then overwritten by correct one
And then AsyncMethodBuilder got that empty context from somewhere
Roger Johansson
@rogeralsing
Apr 27 2015 20:31
ah oke then I might know :) every lambda somehow carries execution context info.. so it might revert back to the context that existed when the async method body was captured?
that is, when we write Receive<Foo>(async foo => {....}); there is no context whenfoo => {...}` is captured, we set that after, manually
Natan Vivo
@nvivo
Apr 27 2015 20:32
all this async stuff is giving me headaches
Roger Johansson
@rogeralsing
Apr 27 2015 20:32
does that make any sense?
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:32
wait
StartNew captures ExecutionContext from where it's called
Natan Vivo
@nvivo
Apr 27 2015 20:33
the current actortaskscheduler is kinda odd
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:33
just where does that lambda gets that empty context
Natan Vivo
@nvivo
Apr 27 2015 20:34
akka.net doesn't use the context from await capture
Roger Johansson
@rogeralsing
Apr 27 2015 20:34
I think the lambda captures the context from where it was declared... so it uses the context of the the constructor of the ReceiveActor (I think)
Natan Vivo
@nvivo
Apr 27 2015 20:34
lmbdas don't capture contexts
context is captured exactly where you put an "await"
otherwise, no context is captured
Task.StartNew won't capture anything, you need to pass state excplicitly in that case, which is what the current code does
that's my understanding at least
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:37
Okay, I've just seen the correct context being passed to Thread.SetExecutionContext and then, boom. ActorCell can't be read
WAT
Natan Vivo
@nvivo
Apr 27 2015 20:37
context is passed because there is an await
but the way actortaskscheduler works, it doesn't use that information to execute the continuation
I'm almost with a solution to this here
Roger Johansson
@rogeralsing
Apr 27 2015 20:39
maybe you guys should work on the same PR?
Natan Vivo
@nvivo
Apr 27 2015 20:39
I'm not working on any pr for now
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:39
This stuff is driving me mad
Natan Vivo
@nvivo
Apr 27 2015 20:39
haha
it's not a simple problem. I doubt we can do some trial and error until it's fixed
Roger Johansson
@rogeralsing
Apr 27 2015 20:40
so, it turns out it was not just me then :)
Natan Vivo
@nvivo
Apr 27 2015 20:40
Roger, I admire you
After a lot of research, I finally understand exactly why you went with this solution
The key now is how to reconcile this with how it should work =)
Roger Johansson
@rogeralsing
Apr 27 2015 20:41
:+1: :)
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:48
Wow. The problem is not with execution context actually
Execution context still has the needed slot
it's container that is empty
argh >_<
The problem is that the context is shared
Natan Vivo
@nvivo
Apr 27 2015 20:49
@kekekeks I already debugged this all the way down. The reason of why things don't work are clear to me
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:50
and original handler erases the ActorCell
Natan Vivo
@nvivo
Apr 27 2015 20:50
The issue now is how to fix it without breaking other things
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:50
structs
these nice immutable things
Natan Vivo
@nvivo
Apr 27 2015 20:51
if you wanna discuss anything, let me know...
I'll keep working on a solution here
Nikita Tsukanov
@kekekeks
Apr 27 2015 20:54
YEAH
HELL YEAH
got it working
Roger Johansson
@rogeralsing
Apr 27 2015 20:56
just you wait :) ..... edge cases.. BUURN j/k
Natan Vivo
@nvivo
Apr 27 2015 20:57
Was I like that 2 months ago? =)
Roger Johansson
@rogeralsing
Apr 27 2015 20:58
wut? you have to be both ISerializable and [Serializable] ?
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:00
yup
the first doesn't work without the second
I'm still curious why xunit tries to serialize that stuff
Roger Johansson
@rogeralsing
Apr 27 2015 21:01
oh, xUnit still blows up?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:01
looking forward to XUnit2 breaking everything when I accept #888
hey, #915 reminds me - we haven't had a tabs vs. whitespaces argument yet
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:05
I'm using TabSanity and don't care anymore
Natan Vivo
@nvivo
Apr 27 2015 21:06
can't this file be kept local?
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:06
it's better for it to be team-shared
yay
I think this should be used instead of #912
Natan Vivo
@nvivo
Apr 27 2015 21:10
I'm done for today
Roger Johansson
@rogeralsing
Apr 27 2015 21:11
nn
@kekekeks close the ones that are obsolete.. I'm all for a CallContext based state container instead of threadstatic. I did try that myself a few months ago, w/o success
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:13
This one seems to work
Roger Johansson
@rogeralsing
Apr 27 2015 21:14
fetching it now, gonna see how it affects the benchmark app
ouch
I know that benchmark app is not showing any real world senario, but we are down from 30+ mil to 15mil msg/sec
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:21
Looks like i should rebase #888 again
Natan Vivo
@nvivo
Apr 27 2015 21:22
@rogeralsing the benchmark you run is the PingPong?
Roger Johansson
@rogeralsing
Apr 27 2015 21:22
yes I know its a silly test, but its a good measure of how slim the pipeline is from Tell to Receive
this needs some serious mono testing before we pull it in
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:25
Any ideas how to improve that?
Natan Vivo
@nvivo
Apr 27 2015 21:26
my laptop goes at 6 mil/sec top on actorbase
Roger Johansson
@rogeralsing
Apr 27 2015 21:26
super hacky approach, if using sync Receive, set threadstatic context, if using async receive , use CallContext... sort of if there is a callcontext, that takes prsedence, if there is none, threadstatic is used
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:27
That's just silly
We can't guarantee that something won't break this way
Roger Johansson
@rogeralsing
Apr 27 2015 21:27
we we are paying for async infrastructure for receive handlers that will in most cases not be async
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:28
async / await is the edge case
not the other way around
Roger Johansson
@rogeralsing
Apr 27 2015 21:28
most actors does not use async await, and still, they pay a 50% throughput penalty now
Natan Vivo
@nvivo
Apr 27 2015 21:28
here we go =)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:29
nothing controversial about it :p
fact of life
Natan Vivo
@nvivo
Apr 27 2015 21:29
I don't agree with that, but let's agree to disagree
=)
Roger Johansson
@rogeralsing
Apr 27 2015 21:30
dont agree to what? that most actors dont use async?
Natan Vivo
@nvivo
Apr 27 2015 21:30
async / await is the edge case
I think it is at most a 50/50
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:30
when it comes to actors, yes they are
This message was deleted
stupid airport wifi
Andrew Skotzko
@skotzko
Apr 27 2015 21:31
oh boy, here we go again
Roger Johansson
@rogeralsing
Apr 27 2015 21:31
haha :)
Natan Vivo
@nvivo
Apr 27 2015 21:31
I'm not here to fight with anyone=)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:31
lol
I just want my high throughput actor systems
Natan Vivo
@nvivo
Apr 27 2015 21:32
I was thinking these days
about this problem
Roger Johansson
@rogeralsing
Apr 27 2015 21:32
yes that should be the default case, a pipelie that is as slim as possible
Natan Vivo
@nvivo
Apr 27 2015 21:32
once C# 6 comes, people will start using pattern matching instead of ReceiveActor
that means some solution will be required at the ActorBase level to do this
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:33
@nvivo 2018 will be a good year, indeed
I will be right there with you
Natan Vivo
@nvivo
Apr 27 2015 21:33
I'm not sure this will take that long
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:33
lol
Roger Johansson
@rogeralsing
Apr 27 2015 21:33
is that even in c#6? I think pattern matching is in c#7?
Natan Vivo
@nvivo
Apr 27 2015 21:33
=)
Roger Johansson
@rogeralsing
Apr 27 2015 21:33
thanks gitter for the fuckup highlight
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:33
lol
I have to keep refreshing gitter these days
Natan Vivo
@nvivo
Apr 27 2015 21:33
haha ok, seriously
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:34
has some race conditions where my messages show up under someone else's name
Natan Vivo
@nvivo
Apr 27 2015 21:34
with pattern matching, UntypedActor will probably be the rule
Roger Johansson
@rogeralsing
Apr 27 2015 21:34
agree on that :)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:34
yeah, pattern matching will be awesome
The F# people will have to suffer us C# people once again plagiarizing their toys
Natan Vivo
@nvivo
Apr 27 2015 21:34
so, maybe without increasing the # of actors, instead of UntypedActor + ReceiveActor, there could be a way to have AsyncActor and SyncActor
this is a long shot, just an idea
not sure how
all I'm saying is that maybe the way to optimize this for thoughput is simply have different code handling both
and still keep a low number of actors to maintain
@rogeralsing , you're right: dotnet/roslyn#2136
BUT
from what I head there on roslyn forum, once C# 6 is finally released with roslyn, they will switch to annual releases
so C# 7 will probably be released along with VS 2016 in a year
and they will just cut features from the list to keep fast releases
that's the plan at least
Roger Johansson
@rogeralsing
Apr 27 2015 21:38
ok, yes but that still at least a year away... I totally agree that untypedactor should be the default then.. but we are here right now
Natan Vivo
@nvivo
Apr 27 2015 21:39
yes, I know. just chatting
Roger Johansson
@rogeralsing
Apr 27 2015 21:40
there was a user on SO the other week that used Akka.NET for high throughput simulations.. it would be lame to have to tell such use "sorry, your out of luck, your stuff will be a lot slower now, but jolly damn we have nice async support in testkit atm"
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:40
lol
Natan Vivo
@nvivo
Apr 27 2015 21:40
hahaha it all depends on how you say it
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:40
I
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:41
For now it's needed to fix broken async/await support in Receive actor
Natan Vivo
@nvivo
Apr 27 2015 21:41
I completely agree async support shouldn't decrease performance just for the sake of it
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:41
"hey, at least you don't have to use an EXTENSION METHOD on your TPL tasks - ewww amirite?"
Stefan Sedich
@stefansedich
Apr 27 2015 21:41
so I woke up today
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:41
Actor shouldn't get killed while processing a message with Suspend behavior
TestKit may be patched around with that custom SyncContext for now
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:41
right there with you @stefansedich
Stefan Sedich
@stefansedich
Apr 27 2015 21:41
usualy I have a week
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:42
I'm going to start anti-async-manifesto.org
and get everyone to sign who wants the keyword abolished from the language
Natan Vivo
@nvivo
Apr 27 2015 21:42
But I also think async/await is important enough to be first class citzen and at some points require tradeoffs to support it correctly
Stefan Sedich
@stefansedich
Apr 27 2015 21:42
I will start asyncmotherfucker.org
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:42
lol
I'm just being silly
it'd be anti-await-manifesto.org
Roger Johansson
@rogeralsing
Apr 27 2015 21:42
I will just eat popcorn as you guys inherited my dirty underwear
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:42
..... uhhh
Natan Vivo
@nvivo
Apr 27 2015 21:42
hahaha
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:42
I vote we stabilize Cluster
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:42
what?
I'm with @annymsMthd
Stefan Sedich
@stefansedich
Apr 27 2015 21:43
have any of you guys got experience with kafka? possibly storm and high throughput ingestion pipelines?
need to pick someones brain
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:43
kafka sucks - no async / await support
Natan Vivo
@nvivo
Apr 27 2015 21:43
auehauehauehaeuh
Stefan Sedich
@stefansedich
Apr 27 2015 21:43
haha bam
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:44
lol no I have no idea about using it
Stefan Sedich
@stefansedich
Apr 27 2015 21:44
I await a serious response
Roger Johansson
@rogeralsing
Apr 27 2015 21:44
deadlock
Natan Vivo
@nvivo
Apr 27 2015 21:44
no context
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:44
oh-you.gif
Roger Johansson
@rogeralsing
Apr 27 2015 21:44
wrong sender
Stefan Sedich
@stefansedich
Apr 27 2015 21:44
oh my you guys offically lost it
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:45
I'm trying really hard to work a PipeTo joke in here but I'm coming up empty
Natan Vivo
@nvivo
Apr 27 2015 21:45
I long for the day I'll say a sentence with "async/await" and @Aaronontheweb will say another with "makes sense"
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:45
NEVER
Stefan Sedich
@stefansedich
Apr 27 2015 21:46
nvivo: "lets kill ayns/await support"
aaron: "makes sense"
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:46
done
I'm onboard
Natan Vivo
@nvivo
Apr 27 2015 21:46
I bet in one or two years you'll say "I guess we should have listened to them..."
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:47
you're lucky that @rogeralsing is the guy to ask about async / await internals - if it were me we'd have this thunderdome style argument where only one contributor gets to walk away alive
Natan Vivo
@nvivo
Apr 27 2015 21:47
haha
Stefan Sedich
@stefansedich
Apr 27 2015 21:47
is async/await like WCF then?
Natan Vivo
@nvivo
Apr 27 2015 21:47
I don't know what's the problem with async/await you complain so much
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:48
I wonder if we just have to make a PR to https://github.com/dotnet/corefx/
Roger Johansson
@rogeralsing
Apr 27 2015 21:48
you mean slow?
then yes :)
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:48
To make that stuff faster
Natan Vivo
@nvivo
Apr 27 2015 21:48
haha
async/await doesn't make anything faster
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:48
@nvivo a couple of reasons
async / await created a future where I inherit code where people do retarded shit like
await Task.Run(async () => {
    //operation that can't benefit from multiple cores
});
it's like Skynet became self-aware and sent a robot back in time to kill me via aneurism induction
Stefan Sedich
@stefansedich
Apr 27 2015 21:50
haha I love seeing that
Natan Vivo
@nvivo
Apr 27 2015 21:50
so, because people kill other people with butter knifes, we should ban butter knifes?
Stefan Sedich
@stefansedich
Apr 27 2015 21:50
Task.Run is like an instant turbo boost
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:50
second
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:50
Nope, we should ban people
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:50
because with Akka.NET specifically
Natan Vivo
@nvivo
Apr 27 2015 21:50
haha that I agree
we should ban people
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:50
where we have a concurrency model that is pretty difficult to fuck up
Natan Vivo
@nvivo
Apr 27 2015 21:50
async/await has nothing to do with concurrency models
absolute zero
Roger Johansson
@rogeralsing
Apr 27 2015 21:51
its all about tears and pain
Natan Vivo
@nvivo
Apr 27 2015 21:51
in fact, async/await has nothing to do with running code
hahaha
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:51
async / await is a life choice
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:51
It's not abount concurrency, it's about sending a mess non-blocking I/O
Stefan Sedich
@stefansedich
Apr 27 2015 21:51
"in fact, async/await has nothing to do with running code" you lost me
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:51
how in the hell can you possibly claim the async / await isn't about concurrency?
Natan Vivo
@nvivo
Apr 27 2015 21:52
it's not
it's not. period =)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:52
the whole idea is to be ABLE TO DO SOMETHING ELSE CONCURRENTLY WHILE I/O HAPPENS
am I taking crazy pills?!?!?
Natan Vivo
@nvivo
Apr 27 2015 21:52
no, it's not
haha
Roger Johansson
@rogeralsing
Apr 27 2015 21:52
I was going to watch an episode of daredevil before bed, but this is way way better :)
Stefan Sedich
@stefansedich
Apr 27 2015 21:52
care to elaborate on why not @nvivo I am lost
Andrew Skotzko
@skotzko
Apr 27 2015 21:52
@nvivo so what is it about then?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:52
sad-keanu.jpg
mfw
Natan Vivo
@nvivo
Apr 27 2015 21:53
i said this many times... if you think of async/await as a way to execute code, it's the wrong concept
async/await is only about waiting values that will be resolved somewhere else
Andrew Skotzko
@skotzko
Apr 27 2015 21:53
@Aaronontheweb hang on a sec, i wanna hear what he has to say
Natan Vivo
@nvivo
Apr 27 2015 21:53
it's a way to wait for promises to be resolved. that's it
it really doesn't care about where code runs, nor affects it
when you see var foo = await bar(), the only thing you can deduce is that "bar() MAY run somewhere else and I cannot get the value now"
Nikita Tsukanov
@kekekeks
Apr 27 2015 21:54
I've used await for dependency-based app initialization once
@nvivo has a point
Andrew Skotzko
@skotzko
Apr 27 2015 21:55
@rogeralsing you should pull up a chair and get some popcorn and a beer for this one
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:55
bah
Stefan Sedich
@stefansedich
Apr 27 2015 21:55
gitter needs to be more like slack
it is a little lacking in the fun department
Natan Vivo
@nvivo
Apr 27 2015 21:56
the point is: if await bar() causes continuations, is because bar() is already scheduled or running somewhere else, out of your control. await just helps you continue after that value is produced
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:56
I have hipchat because we poor. We do have a hubot though
Andrew Skotzko
@skotzko
Apr 27 2015 21:56
@annymsMthd isn’t slack….free?
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:56
idk
Harlan
@harlannorth
Apr 27 2015 21:56
Free with limit
s
Stefan Sedich
@stefansedich
Apr 27 2015 21:56
yeah but if you want to keep history you gotta pay
Roger Johansson
@rogeralsing
Apr 27 2015 21:56
yes, free but only 100k searchable messages
Stefan Sedich
@stefansedich
Apr 27 2015 21:56
that is how they got us, I wanted to search one day back for something important.
had to pay
Andrew Skotzko
@skotzko
Apr 27 2015 21:57
ah. ok
Natan Vivo
@nvivo
Apr 27 2015 21:57
my connection is shit today... batching tons of messages at once
Stefan Sedich
@stefansedich
Apr 27 2015 21:57
async connection?
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:58
:clap:
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:58
@nvivo ok, so you understand that Promises are literally defined as concurrent programming constructs - right? http://en.wikipedia.org/wiki/Futures_and_promises
and Task is a future
Natan Vivo
@nvivo
Apr 27 2015 21:58
yes
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:58
ok
Joshua Benjamin
@annymsMthd
Apr 27 2015 21:58
I think we need a ven diagram
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:58
so, if the idea is that await serializes a block of code into memory to be re-hydrated once the promise is fulfilled
Natan Vivo
@nvivo
Apr 27 2015 21:59
that's not what happens
Aaron Stannard
@Aaronontheweb
Apr 27 2015 21:59
what's the point of doing that if not to allow other code to run concurrently?
Natan Vivo
@nvivo
Apr 27 2015 21:59
await serializes a block of code into memory to be re-hydrated once the promise is fulfilled
Roger Johansson
@rogeralsing
Apr 27 2015 21:59
....
Natan Vivo
@nvivo
Apr 27 2015 21:59
LOL
Stefan Sedich
@stefansedich
Apr 27 2015 22:00
huh @nvivo what @Aaronontheweb says about await is exactly as I understand what is going on?
Natan Vivo
@nvivo
Apr 27 2015 22:00
first thing is that await makes some decisions. if the task is completed, nothing happens. it's just syncrhonous code
continuations are scheduled only if you are already running a task somewhere
so, await task doesn't mean continuations will be scheduled
it means that continations MAY be scheduled if there is no other way to proceed
Stefan Sedich
@stefansedich
Apr 27 2015 22:01
isn't that just an implementation detail? at a high level what @Aaronontheweb said is right.
Natan Vivo
@nvivo
Apr 27 2015 22:01
it's not right because await does literally nothing in a lot of cases
Natan Vivo
@nvivo
Apr 27 2015 22:01
for example, var foo = await Task.FromResult("bar") is exactly like var foo = "bar"
Stefan Sedich
@stefansedich
Apr 27 2015 22:02
I eject back to the popcorn with @rogeralsing
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:02
@nvivo no dude, that's not how the english language works
you don't get to take the fundamental thing that something does
and dismiss is based on one edge case
Natan Vivo
@nvivo
Apr 27 2015 22:02
?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:02
and then claim that edge case is most cases
the common case that await is for
i.e. the reason anyone uses it in the first place
is for exactly what I said
because rather than blocking a thread, you get to create a continuation off of a completed promise that executes asynchronously
Natan Vivo
@nvivo
Apr 27 2015 22:03
the reason someone uses it is because they are working with tasks, not because they want to run something in parallel
that assumption is just wrong
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:03
parallelism != concurrency, yes
but concurrency is bigger than parallelism
Natan Vivo
@nvivo
Apr 27 2015 22:03
running something in parallel is something tasks can do
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:03
async = concurrency
Natan Vivo
@nvivo
Apr 27 2015 22:03
it's not the reason async/await exist
those are different things
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:04
concurrency is the big circle
parallelism and asynchronous programming are little circles inside of it
Natan Vivo
@nvivo
Apr 27 2015 22:04
the common case for "await" is just "I have this task, I don't know when it will be done, I need to wait for it to finish"
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:04
that's why, per wikipedia, promises and tasks are concurrent programming constructs
Natan Vivo
@nvivo
Apr 27 2015 22:05
the fact you decided to start a task to do something in parallel is a different thing
Roger Johansson
@rogeralsing
Apr 27 2015 22:05
tbh, I side with @nvivo on this one, the standard case for async is just one single thread of execution, even if that thread is broken up in a lot of different software threads... a full awaited flow only does one thing at a time
Natan Vivo
@nvivo
Apr 27 2015 22:06
WOW. Someone agrees with me =)
Roger Johansson
@rogeralsing
Apr 27 2015 22:06
take an async web api method, and go async all the way down from top to bottom, for that request, there is never multipe blocks of code executing at once.. unless you do Task.WhenAll or something like that
Natan Vivo
@nvivo
Apr 27 2015 22:07
yes, and the fact async/await is supposed to guard a method, not an application
local variables are guaranteed to be set in order. properties and anything else aren't
Roger Johansson
@rogeralsing
Apr 27 2015 22:08
in the standard usecase, there is nothing concurrent about it, it executes one thing at a time.. but executing on different places, but in a serialized way
Joshua Benjamin
@annymsMthd
Apr 27 2015 22:08
So you are allowing several requests the ability to share a thread?
Natan Vivo
@nvivo
Apr 27 2015 22:09
what is a request?
Joshua Benjamin
@annymsMthd
Apr 27 2015 22:09
in the ASP.net model
Roger Johansson
@rogeralsing
Apr 27 2015 22:09
that is like saying that synchronous code is concurrent just because multiple requests can run on many threads at the same time
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:10
@rogeralsing @nvivo ok boys and girls, gather around
Natan Vivo
@nvivo
Apr 27 2015 22:10
here we go again... :-D
Roger Johansson
@rogeralsing
Apr 27 2015 22:10
the code itself in isolation, is a single synchronous flow, even if it is broken up in peices
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:10
YES, a single async workflow executes in serial steps
the entire point of it being ASYNCHRONOUS is so OTHER CODE can execute CONCURRENTLY
including other instances of the async workflow
that is literally the entire point
Natan Vivo
@nvivo
Apr 27 2015 22:11
asynchronous is not async/await feature
async/await is a feature of the language with a bad name
jberzy
@jberzy
Apr 27 2015 22:11
Sorry to chime in here (I am probably out of my depth) but, how about IO completion ports?
Natan Vivo
@nvivo
Apr 27 2015 22:11
what about them?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:11
@jberzy yep, those are usually inside inside awaitable APIs
they're an asynchronous programming primitive expose by Windows for I/O
Natan Vivo
@nvivo
Apr 27 2015 22:12
let's see it this way: async/await could be replaced by "maybe this is async/maybe we need to wait"
jberzy
@jberzy
Apr 27 2015 22:12
ok I might not be understanding the arguments so I'll sit back
Natan Vivo
@nvivo
Apr 27 2015 22:12
although I'm sure those keywords would be harder to type
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:12
the entire point of all of this shit is to be able to build responsive applications that can do multiple things at once, rather than get tied up waiting for things to finish
Natan Vivo
@nvivo
Apr 27 2015 22:13
The point of Akka is to do that
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:13
the point of all asynchronous programming is to do that
that's why the field exists
what the fuck would be the point of waiting on something if you have nothing else to do?
Natan Vivo
@nvivo
Apr 27 2015 22:13
you're mixing the stuff
you can't say async/await and an entire field are the same thing
async/await is just a syntatic sugar to do what you'd like to do in most cases but it's too boring to do
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:14
dude, I get it - it's sugar on top of the TPL
Natan Vivo
@nvivo
Apr 27 2015 22:14
what the fuck would be the point of waiting on something if you have nothing else to do?
the point is only not blocking the thread
that's all
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:15
IN ORDER TO DO OTHER STUFF
Roger Johansson
@rogeralsing
Apr 27 2015 22:15
FOR SOMEONE ELSE
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:15
THAT'S WHAT WE CARE ABOUT NOT BLOCKING THE THREAD IN THE FIRST PLACE
Natan Vivo
@nvivo
Apr 27 2015 22:15
exactly!
Roger Johansson
@rogeralsing
Apr 27 2015 22:15
you who await, is not doing something else
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:15
In order to wait for something else, for example
Natan Vivo
@nvivo
Apr 27 2015 22:15
@rogeralsing achievement unlocked!
Joshua Benjamin
@annymsMthd
Apr 27 2015 22:15
but the thread is
Natan Vivo
@nvivo
Apr 27 2015 22:15
you don't block because other requests might be doing something
Natan Vivo
@nvivo
Apr 27 2015 22:15
not because that method needs to do something else
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:15
that "someone else" is yourself!
Natan Vivo
@nvivo
Apr 27 2015 22:16
depends on what is "yourself"
if it means your app, then it is =)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:16
yes, your app
Natan Vivo
@nvivo
Apr 27 2015 22:16
but what we mean is another request
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:16
ThreadPool is shared between apps in IIS
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:16
no one uses async / await because they give care about other people's apps - altruistic concurrent programming isn't a thing :p
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:16
So it might be another app
that wants to do stuff
Natan Vivo
@nvivo
Apr 27 2015 22:17
@Aaronontheweb you're missing the point either on purpose or because you don't want to agree with me =)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:17
I'm not missing anything dude
Natan Vivo
@nvivo
Apr 27 2015 22:17
yes, you are
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:17
the point of all of these tools is for responsive programming on multi-core systems
Natan Vivo
@nvivo
Apr 27 2015 22:17
you don't block to free the thread when it can be freed, period
what happens to that thread is not your problem
what matters is that you're not blocking things unecessarily
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:18
you're pigeonholing on autistic details and missing the big picture
Natan Vivo
@nvivo
Apr 27 2015 22:18
I am?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:18
yes dude
Natan Vivo
@nvivo
Apr 27 2015 22:18
no, you are =)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:18
had to go with a great gif for this
please don't take it personally :p
oh-no-she-didnt.gif
Natan Vivo
@nvivo
Apr 27 2015 22:18
haha go ahead
Joshua Benjamin
@annymsMthd
Apr 27 2015 22:19
I think we just need to go back to basics here. Define concurrency
Natan Vivo
@nvivo
Apr 27 2015 22:19
hahaha
ok, @annymsMthd let's go with the basics then
Joshua Benjamin
@annymsMthd
Apr 27 2015 22:19
What is the definition of concurrency?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:19
Concurrent computing is a form of computing in which several computations are executing during overlapping time periods – concurrently – instead of sequentially (one completing before the next starts).
Natan Vivo
@nvivo
Apr 27 2015 22:19
right
Joshua Benjamin
@annymsMthd
Apr 27 2015 22:20
does it say anything about threads?
or what those computations are doing?
Natan Vivo
@nvivo
Apr 27 2015 22:20
no. you may run a single thread or many
concurrency is not parallelism
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:20
his is a property of a system – this may be an individual program, a computer, or a network – and there is a separate execution point or "thread of control" for each computation ("process"). A concurrent system is one where a computation can make progress without waiting for all other computations to complete – where more than one computation can make progress at "the same time".
Joshua Benjamin
@annymsMthd
Apr 27 2015 22:21
So primitives like mutex and semaphore are considered to be part of concurrency?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:21
Parallel computing is a form of computation in which many calculations are carried out simultaneously,[1] operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently ("in parallel").
Natan Vivo
@nvivo
Apr 27 2015 22:21
Thanks Wikipedia =)
Roger Johansson
@rogeralsing
Apr 27 2015 22:21
...
jberzy
@jberzy
Apr 27 2015 22:21
haha
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:22
so, using literally the opening sentences for concurrent programming and asynchronous / parallel programming above
parallel programming is concurrent
concurrent programming is not necessarily parallel
Natan Vivo
@nvivo
Apr 27 2015 22:22
exactly
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:22
ok, that's what I've been arguing this entire time
Natan Vivo
@nvivo
Apr 27 2015 22:22
where are we going with this?
weren't we talking about what async/await does?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:23
async / await is task-based parallelism
Roger Johansson
@rogeralsing
Apr 27 2015 22:23
ok lets phrase it like this then, async await enables concurrency by freeing up treads for others to use... but for the code using await, it doesn't give you any concurrency features
Natan Vivo
@nvivo
Apr 27 2015 22:23
no, it's not
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:23
yes it is - don't get started on the literal details of the keywords
Natan Vivo
@nvivo
Apr 27 2015 22:23
@rogeralsing right
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:23
look at what the tool's intention is
and how it's used
Natan Vivo
@nvivo
Apr 27 2015 22:23
@rogeralsing you're mixing concepts
ops
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:24
it's primary use is to simplify the task-based parallelism model the TPL exposes
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:24
no, I am not
Natan Vivo
@nvivo
Apr 27 2015 22:24
@Aaronontheweb yes you are
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:24
listen
put the pencil down
stop typing
Natan Vivo
@nvivo
Apr 27 2015 22:24
you're trying to make async/await an entire concept it was never made to represent
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:24
and just listen
Natan Vivo
@nvivo
Apr 27 2015 22:24
async/await is a language feature, very simple and does one thing only
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:24
seriously dude, just stop for a second
just stop it
Natan Vivo
@nvivo
Apr 27 2015 22:24
it allows you to write code that looks syncrhonous but is not
@Aaronontheweb you're wrong =)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:25
the bottom line behind this language feature is to make it easier to write TPL code
Natan Vivo
@nvivo
Apr 27 2015 22:25
sorry, it's just a fact
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:25
dude, if you're not going to listen
Natan Vivo
@nvivo
Apr 27 2015 22:25
we can call Stephen Cleary here
haha
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:25
then why I am wasting my time trying to explain?
Natan Vivo
@nvivo
Apr 27 2015 22:25
go ahead, won't say anything
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:25
you're talking at an extremely low level
and frankly speaking like a middlebrow programmer who cares more about being "right" than understanding the level that I'm talking at
so listen to what I'm actually trying to say
rather than look for a reason why I'm wrong
and maybe others, like me, will do the same for you
ok.
so the bottom line is - forget what the literal machine code does
look at the concepts from an API design point of view
the actor model and the TPL are both concurrent programming constructs
Roger Johansson
@rogeralsing
Apr 27 2015 22:28
absolutely, but TPL != await keyword.. I think that is the main issue in this discussion
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:28
designed to make the process of building responsive applications that can successfully leverage multiple cores
@rogeralsing SUSH
Natan Vivo
@nvivo
Apr 27 2015 22:28
haha
sorry
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:29
they are both concurrent programming constructs, this is firmly in the realm of fact
what the async / await keywords introduce is an additional layer on top of the TPL and some of the other concurrency mechanisms built into .NET / Windows, like I/O completion ports
the details of how those are implemented is not relevant to this discussion
it simply isn't
let go
what's important, and why this has been a contentious issue
is that the async / await model muddies the waters on what actually happens when it runs
as you yourself said
lots of decisions get made before the code runs
on the other side of the table
Natan Vivo
@nvivo
Apr 27 2015 22:31
let me know when I can say something
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:31
the actor model has a very well-defined mode of behaving concurrently
not yet
one thing at a time per actor
the TPL itself plays nicely with this model when you use PipeTo
async / await however, does not - by being as smart as it is it makes to harder to reason about what the actor actually does
when it hits that block
this has been the source of contention
it conflicts with the clarity and ease of programming with the actor model for benefits that are not well defined and easy to dispute
so circling back to the point I was making
regardless of the implementation details (and seriously, let go of that) - these constructs both represent concurrent programming models with different views of how things should be done
the actor model tries to force explicit choices
async / await makes implicit ones unbeknownst to you
and these are often at odds
that's the crux of the argument as I see it
Natan Vivo
@nvivo
Apr 27 2015 22:35
may I say something sir?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:35
go for it
I'm finished
Natan Vivo
@nvivo
Apr 27 2015 22:36
I think you don't understand what async/await is, what it does, how it works and how simple it is. Thus, you argument is flawed. =)
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:36

async / await however, does not - by being as smart as it is it makes to harder to reason about what the actor actually does

Just get rid of that AsyncBehavior.Reentrant and it would also play nicely with actor model

Natan Vivo
@nvivo
Apr 27 2015 22:36
You're very very bright guy. But in this specific topic, you're just wrong. sorry
Roger Johansson
@rogeralsing
Apr 27 2015 22:36
:+1: on @kekekeks
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:36
:+1: on @kekekeks
Natan Vivo
@nvivo
Apr 27 2015 22:37
I'm not trying to offend you @Aaronontheweb
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:37
ok, help me understand @nvivo
Natan Vivo
@nvivo
Apr 27 2015 22:37
we're discussing as man here
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:37
don't worry about my feelings :p - I'm a big boy
Natan Vivo
@nvivo
Apr 27 2015 22:38
Akka is a programming model, to build asynchronous applications
async/await is a programming model to build asyncrhonous methods
an application may be composed of syncrhnous or asyncrhonous methods. but they aren't the same thing
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:39
yep, with you so far
Natan Vivo
@nvivo
Apr 27 2015 22:39
they don't conflict. akka is at a higher level
I want to take the asp.net example
although I'm aware akka is not asp.net (so let it go)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:39
haha
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:39
They do conflict when message handler is reentrant
Natan Vivo
@nvivo
Apr 27 2015 22:39
wait for it
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:40
Closure might capture the state, actor gets restarted/killed/whatever, kaboom
Natan Vivo
@nvivo
Apr 27 2015 22:40
asp.net receives a request. The request is one, but there might be multiple continuations scheduled
still, the request is one
asp.net doesn't care how the code to handle that request is handled
as long as it starts and finishes
akka.net is the same. the message processing model cares that messages are processed one at a time
Roger Johansson
@rogeralsing
Apr 27 2015 22:41
except that the actor model doesnt force one message at a time, just to confuse the shit out of everyone.. if an actor does not care about Become behavior, it is allowed to process messages in parallel.. according to Carl Hewitt himself... see chan9 vid with him ... but it can enforce one message at a time if it needs to
Natan Vivo
@nvivo
Apr 27 2015 22:41
well, I'm talking about the actor model in akka.net
Roger Johansson
@rogeralsing
Apr 27 2015 22:41
and Akka and Erlang goes down that route by default
Natan Vivo
@nvivo
Apr 27 2015 22:42
let's be honest. being strict to documents from 1970 didn't help mvc, and won't help actor models =)
I know that akka at least tries to process 1 message at a time
per actor
and the fact is that async/await has nothing to do with that.
async/await makes a single method execute in non-blocking, it doesn't make your application parallel. that's something you need other constructs to do it
a processor runs syncrhnous code in parallel, but that doesn't matter for the code you run
Roger Johansson
@rogeralsing
Apr 27 2015 22:43

async/await makes a single method execute in non-blocking, it doesn't make your application parallel. that's something you need other constructs to do it

this..

Natan Vivo
@nvivo
Apr 27 2015 22:43
it's a detail
so, saying async/await conflicts with akka model is non-sense to me
they act at different levels. very different levels
I believe it's possible to make them work just fine together. orleans does that, it works. (and I know akka is not orleans, let go)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:45
async/await makes a single method execute in non-blocking, it doesn't make your application parallel. that's something you need other constructs to do it
Isn't this like saying having an open socket connection doesn't make your application a network application, because you need other stuff to write to it?
that
Natan Vivo
@nvivo
Apr 27 2015 22:45
no, i don't think so
honestly
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:45
so here's where you and I disagree
to put a fine line on it
They do conflict when message handler is reentrant
Natan Vivo
@nvivo
Apr 27 2015 22:46
i don't think it's a good analogy
ok, but this
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:46

async / await however, does not - by being as smart as it is it makes to harder to reason about what the actor actually does

I believe, orleans doesn't have reentrancy, does it?

Natan Vivo
@nvivo
Apr 27 2015 22:46
this specificaly
has nothing to do with async/await. it has to do only with how you want to use async/await
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:46
the bottom line is that in the concurrency model that akka, akka.net, and erlang adopt
Roger Johansson
@rogeralsing
Apr 27 2015 22:46
@Aaronontheweb take the suspend behavior (if sys msgs was also suspended) . do you not agree that the semantics of a sync actor vs an async await receive method is exactly the same?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:47
the receive method does have a very specific way of being executed
and it's synchronous
and not re-entrant
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:47
It's not about async/await, it's about not touching the actor while it still haven't processed the message.
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:47
yes @kekekeks
that's exactly what I care about
Natan Vivo
@nvivo
Apr 27 2015 22:47
@Aaronontheweb see roger's question
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:48
roger's question is right - in that scenario the behavior is correct
Natan Vivo
@nvivo
Apr 27 2015 22:48
so, that's what I'm saying all along.
choosing reentrancy is an akka concept, not async/await concept
async/await has nothing to do with that.
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:49
we can disagree on the semantics of that
but for all intents and purposes
Natan Vivo
@nvivo
Apr 27 2015 22:49
just like if you want to run 2 threads changing the same object without any locks, something will go wrong. but it's not the method's fault. it's the person using them this way
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:49
we're cool if there's no re-entrant behavior on the Receive loop
Natan Vivo
@nvivo
Apr 27 2015 22:49
Aaron
one of the things I advocated before is that PipeTo works with async/await just fine
and both serve different purposes
I think one of the issues in all of this discussion is that you always think about actors and talking to actors and running code in parallel
my intent on using async has nothing to do with that
Stefan Sedich
@stefansedich
Apr 27 2015 22:50
"just like if you want to run 2 threads changing the same object without any locks, something will go wrong. but it's not the method's fault. it's the person using them this way"
isn't that one benefit of the actor model, it is hard to get into this mess?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:51
isn't that one benefit of the actor model, it is hard to get into this mess?
YES
Natan Vivo
@nvivo
Apr 27 2015 22:51
@stefansedich yes.
we all agree on this
so
Stefan Sedich
@stefansedich
Apr 27 2015 22:51
well it should not be possible to get into that mess
Natan Vivo
@nvivo
Apr 27 2015 22:51
hear this
consider that akka model is "I'll send the actor a message, and I promise I won't send you another until you're done with that"
correct?
Roger Johansson
@rogeralsing
Apr 27 2015 22:52
regarding reentrancy, that is sugar ontop of PipeTo.. it might not be clear that it is, but that is exactly what it does.. so nothing runs in parallel, but each await block runs concurrently on the actor mailbox
Natan Vivo
@nvivo
Apr 27 2015 22:52
@Aaronontheweb correct?
simple question
he's off
@stefansedich
ok, he is back
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:54
airport wifi is a fickle thing
so here's the thing, considering throughput with async / await with mailbox suspensions
Natan Vivo
@nvivo
Apr 27 2015 22:54
wait
my turn
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:54
LOL
ok
Natan Vivo
@nvivo
Apr 27 2015 22:55
so.. akka promises to not send 2 messages at a time, right?
to the same actor
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:55
nope
Natan Vivo
@nvivo
Apr 27 2015 22:55
nope?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:55
actor only processes 1 message at a time
Natan Vivo
@nvivo
Apr 27 2015 22:55
that's what I said
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:55
oh wait, I think we're saying the same thing
Natan Vivo
@nvivo
Apr 27 2015 22:55
=)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:55
sending a message refers to going into the mailbox
Natan Vivo
@nvivo
Apr 27 2015 22:55
you just want to disagree with me
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:55
processing is consuming from it
Natan Vivo
@nvivo
Apr 27 2015 22:56
ok
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:56
no no
Natan Vivo
@nvivo
Apr 27 2015 22:56
so, continuing
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:56

so here's the thing, considering throughput with async / await with mailbox suspensions

It will only be suspended if handler haven't completed synchonously. When there is some stuff to await, throughput wouldn't be that great anyway. So no tradeoff here.

Natan Vivo
@nvivo
Apr 27 2015 22:56
akka sends messages one at a time.. but this is because akka wants to do that. there is nothing on c# that prevents akka from sending 2 messages to the same actor
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:57
@kekekeks my point was going to be that it'd be less impactful to just PipeTo yourself and achieve the same result without suspension
Natan Vivo
@nvivo
Apr 27 2015 22:57
in the same sense, the fact you can send 2 messages to an actor while it's in the middle of an async method it your choice
there is nothing in the language that implies that. akka controls this behavior
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:57

my point was going to be that it'd be less impactful to just PipeTo yourself and achieve the same result without suspension

There are cases when you just can't process anything else before processing the current message

Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:57
behavior-switching dawg
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:58
this will overcomplicate the logic
Natan Vivo
@nvivo
Apr 27 2015 22:58
@Aaronontheweb makes sense until this point?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 22:58
I understand what you're saying
Natan Vivo
@nvivo
Apr 27 2015 22:58
right
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:59
especially when you need to perform 3-5 async operations in particular order and then decide what to do with the message
Stefan Sedich
@stefansedich
Apr 27 2015 22:59
@nvivo "akka sends messages one at a time.." isn't that processes one at a time?
Nikita Tsukanov
@kekekeks
Apr 27 2015 22:59
it will be become-spagetty
Stefan Sedich
@stefansedich
Apr 27 2015 22:59
you can send as many as you like
Natan Vivo
@nvivo
Apr 27 2015 22:59
@stefansedich yes.
@stefansedich yep. sorry, that's what I meant
Stefan Sedich
@stefansedich
Apr 27 2015 22:59
cool assumed so, just clearing it up as I am confused enough as it is.
Natan Vivo
@nvivo
Apr 27 2015 23:00
So, in the end, i come back to the fact that async/await does not conflict with akka in any way.
it's akka that decided to use it in a confusing way before. it's not c#'s fault =)
as Roger said, removing Reentrant for async solves that
can we agree on this at least?
Roger Johansson
@rogeralsing
Apr 27 2015 23:01
I think all parties already have
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:01
already did I thought
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:01
So, The Plan:
1) drop support for AsyncBehavior.Reentrant, avoid it like the devil it is
2) pause not only regular, but also system message queue
3) (optional) add some explicit sugar for PipeTo via a custom awaiter or something like that
Natan Vivo
@nvivo
Apr 27 2015 23:02
I'd be glad on agreeing for today and leaving plans for tomorrow
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:02
why should system messages not be paused?
Natan Vivo
@nvivo
Apr 27 2015 23:02
but I guess 3 is not required
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:02
err, be paused
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:02

why should system messages not be paused?

because actor shouldn't be killed while still processing a message?

Natan Vivo
@nvivo
Apr 27 2015 23:03
async processing is just like sync processing
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:03
yep, and that's ok if the actor gets killed while that's happening
Natan Vivo
@nvivo
Apr 27 2015 23:03
if you can't kill an actor while it's running syncrhonously, you shouldn't when it's async
in fact... it's all about the rule of 1 at a time. async receive shouldn't change that
you need to wait until the async process finishes to process something else
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:03
If you don't run the continuation, some finallymight never run
And that may cause a lot of weird things to happen
Don't do it
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:04
eh, I just don't like the idea of actors not being able to reboot
waiting for an async message that never comes
Natan Vivo
@nvivo
Apr 27 2015 23:04
yes.. but I'd like to talk about the motivations
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:04
it's already unable to reboot when it's processing a message
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:04
but what you're saying makes sense
Natan Vivo
@nvivo
Apr 27 2015 23:04
for async. I think that talking to actors is not the main motivation
it's possible to have a timeout just like for messages. but I think the rule should be: handle async the same way sync code
if there is no protection for an infinite loop, there is no protection for a never ending task
Roger Johansson
@rogeralsing
Apr 27 2015 23:05
@Aaronontheweb this is exactly the reason I kept sys messages on for suspend behavior... but if we want to go for exactly the same semantics, then they also should be suspended.. I see pros and cons with both
Natan Vivo
@nvivo
Apr 27 2015 23:05
(although it might be good to add one)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:05
ok, well they have a point
if someone writes an actor that deadlocks itself
i.e. waits on a Task the old fashioned way
guess it's kind of screwed
Roger Johansson
@rogeralsing
Apr 27 2015 23:06
that can happen in a sync actor too though
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:06
yep, that's what I meant
Natan Vivo
@nvivo
Apr 27 2015 23:07
I think in practice it would be hard for that to happen if we give patterns for people to follow
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:07
inside any synchronously running actor
it'd have the same problem
so @kekekeks plan makes sense
Roger Johansson
@rogeralsing
Apr 27 2015 23:07
so should we kill of the reentrant behacior?
Natan Vivo
@nvivo
Apr 27 2015 23:07
see, for me async /await is not to use Ask
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:07
yeah
burn it with fire
Natan Vivo
@nvivo
Apr 27 2015 23:07
@Aaronontheweb so, async/await makes sense? (LOL)
Roger Johansson
@rogeralsing
Apr 27 2015 23:08
he already agreed that suspend was ok ;)
Natan Vivo
@nvivo
Apr 27 2015 23:08
LOL
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:08
yeah I caved on that one a long time ago
Roger Johansson
@rogeralsing
Apr 27 2015 23:08
you guys have to chill down and get out of fight or flight mode :)
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:08
like before v1 shipped long time ago
suspension is ok
but reentrant is evil
Natan Vivo
@nvivo
Apr 27 2015 23:09
ok, so now I'm not arguing with anyone. I'd just like to discuss something a little different but related
I'd like to talk about when use async and when use pipeto
Roger Johansson
@rogeralsing
Apr 27 2015 23:09
its 1 am here. i have to work tomorrow, or well,, today...
Natan Vivo
@nvivo
Apr 27 2015 23:09
oh, right!
forgot about that
we can talk another day
but I guess was a productive discussion
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:09
I was promised an argument about tabs and spaces now
Natan Vivo
@nvivo
Apr 27 2015 23:10
haha
Roger Johansson
@rogeralsing
Apr 27 2015 23:10
cc @kekekeks that was your discussion, right?
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:10
Tabs for indentation, spaces for formatting!
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:10
NEVER
Natan Vivo
@nvivo
Apr 27 2015 23:10
NEVER
Roger Johansson
@rogeralsing
Apr 27 2015 23:10
like if some word is a bit off in ms word, we use space to place it where we want, am I rite?
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:10
FOLLOW THE VIM WAY, YOU HERETICS
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:11
EMACS OR DIE
I WILL CUT YOU
Stefan Sedich
@stefansedich
Apr 27 2015 23:11
notepad.exe or die
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:11
(i actually have no idea what emacs does)
Stefan Sedich
@stefansedich
Apr 27 2015 23:11
I am smart enough not to need a big undo stack
Roger Johansson
@rogeralsing
Apr 27 2015 23:11
IM ALMOST NAKED!
just thought I should throw that in here..
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:11
I WILL HM01 YOU
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:12
lol
so do I need to merge this thing in #915?
Natan Vivo
@nvivo
Apr 27 2015 23:12
@rogeralsing hahaha that's what I call sleepy drunk
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:12
I'm at an airport and not drunk - frankly this feels wrong
it's ALLasync / awaitS FAULT
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:13
#915 just adds some hints to .editorconfig-aware tools, that this project uses spaces. So it's perfectly safe to merge
Natan Vivo
@nvivo
Apr 27 2015 23:13
I'll propose C# 8 to change it to tab/space
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:13
I kid I kid
Natan Vivo
@nvivo
Apr 27 2015 23:13
tab Task Foo() { spaces bar(); }
makes sense to me
Roger Johansson
@rogeralsing
Apr 27 2015 23:13
so now that everyone agrees on suspend.. how the f... do we flow the implicit context? .. over to @nvivo and @Aaronontheweb :)
im off :) nn
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:14
later
Natan Vivo
@nvivo
Apr 27 2015 23:14
haha don't look at me. I just throw wood in the fire
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:14
I leave it to your capable hands @nvivo and @kekekeks
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:14
Since anything other than ThreadStatic just turns Akka into a slopoke, we should leave the current method
Natan Vivo
@nvivo
Apr 27 2015 23:14
@kekekeks you name sounds like you're laughing to me
don't ask me why... that's how brazilian people laugh on the internet sometimes
"kekeke"
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:15
It's korean thing, actually
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:15
StarCraft 2
and Brood War if you're OG
Natan Vivo
@nvivo
Apr 27 2015 23:16
never played
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:16
it's pretty intense
but also kind of hilarious
Natan Vivo
@nvivo
Apr 27 2015 23:17
I only play Creeper World 3 now
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:17
after I get back to LA I promise to check out #888 @annymsMthd
so we can finally put that sucker to bed
Nikita Tsukanov
@kekekeks
Apr 27 2015 23:17
Original nickname was "keks-n", but due to some circumstances and some funny fellow, it turned to "kekekeks"
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:17
going to release v1.0.1 tomorrow to get some of the bug fixes out
we'll do another release for more of the async / await stuff
Natan Vivo
@nvivo
Apr 27 2015 23:18
@kekekeks right. makes sense!
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:18
big fan of doing that regularly
Natan Vivo
@nvivo
Apr 27 2015 23:18
big fan of doing async/await regularly?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:18
pushing releases
Natan Vivo
@nvivo
Apr 27 2015 23:18
jk
Natan Vivo
@nvivo
Apr 27 2015 23:19
:-D
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:19
used the same gif twice in 2 hours
oh-you.gif
probably a rule against that
Natan Vivo
@nvivo
Apr 27 2015 23:19
@Aaronontheweb talking about another thing
docs
seriously now
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:20
I have less than 5 minutes - go fast
gotta board soon
Natan Vivo
@nvivo
Apr 27 2015 23:20
I was looking at updating the Actor Lifecycle, and it looks strange to have a single page to that
in tha akka docs they are merged with another page talking about actors in general
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:21
make them human-friendly
even if that means breaking them up
Natan Vivo
@nvivo
Apr 27 2015 23:21
yeah, but I think while the documentation of the preStart, postStop etc makes sense in the "working with actors"
the part of explaining lifecycle seems to be more of "concepts"
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:22
that makes sense
Natan Vivo
@nvivo
Apr 27 2015 23:23
I'll see if I can split them, keep a lifecycle page split but in the other section. see how it goes. ok?
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:23
sounds good to me
Natan Vivo
@nvivo
Apr 27 2015 23:23
ok. I'll go now... have to have sex with my wife
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:23
whatever seems natural and human
Natan Vivo
@nvivo
Apr 27 2015 23:23
I mean
haha nevermind
Aaron Stannard
@Aaronontheweb
Apr 27 2015 23:24
doggie-dance.gif
welp, that was the wrong gif
time for me to go
Natan Vivo
@nvivo
Apr 27 2015 23:25
=) bye have an nice flight