Swift Concurrency and Actor model


(Gerard Iglesias) #1

Hi,

I am working at the moment on a job which involves Scala and Akka, the kind of stuff which involve network, bid data, raw computing (Ai related) and scalability… Well buzz words of our time.

I would like to make the like in the swift world… Swift, GCD, Vapor or Perfect… To conduct some benchmark to compare the different approaches.

Do you see some other interesting technology worth to look at for this kind of things ?

Thank in advance.

Gerard


(Maxim Veksler) #2

Hi Gerald,

It might be only me I'm not sure what you are suggesting. I would agree
that Swift Server could benefit greatly from an Actor Model framework, and
Swift in general would probably benefit greatly from co-routines.

There is a Swift Server API's working group https://swift.org/server-apis/ it's
for discussing lower level building blocks (network, HTTP, TLS) but is
probably the most likely starting point for such discussions.

HTH.

···

On Sun, Apr 2, 2017 at 9:48 PM Gerard Iglesias via swift-users < swift-users@swift.org> wrote:

Hi,

I am working at the moment on a job which involves Scala and Akka, the
kind of stuff which involve network, bid data, raw computing (Ai related)
and scalability… Well buzz words of our time.

I would like to make the like in the swift world… Swift, GCD, Vapor or
Perfect… To conduct some benchmark to compare the different approaches.

Do you see some other interesting technology worth to look at for this
kind of things ?

Thank in advance.

Gerard
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Proyb P) #3

Yeah, I believe Gerard know that, he have been discussed in Vapor slack
channel.

To add on, Gerard might want to try .Net core and Kotlin.

···

On Sat, Apr 8, 2017 at 4:52 AM, Maxim Veksler via swift-users < swift-users@swift.org> wrote:

Hi Gerald,

It might be only me I'm not sure what you are suggesting. I would agree
that Swift Server could benefit greatly from an Actor Model framework, and
Swift in general would probably benefit greatly from co-routines.

There is a Swift Server API's working group https://swift.org/server-apis/ it's
for discussing lower level building blocks (network, HTTP, TLS) but is
probably the most likely starting point for such discussions.

HTH.

On Sun, Apr 2, 2017 at 9:48 PM Gerard Iglesias via swift-users < > swift-users@swift.org> wrote:

Hi,

I am working at the moment on a job which involves Scala and Akka, the
kind of stuff which involve network, bid data, raw computing (Ai related)
and scalability… Well buzz words of our time.

I would like to make the like in the swift world… Swift, GCD, Vapor or
Perfect… To conduct some benchmark to compare the different approaches.

Do you see some other interesting technology worth to look at for this
kind of things ?

Thank in advance.

Gerard
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Gerard Iglesias) #4

My question was about if something has been made on this field, something like "scalable server in swift" that means somewhere cluster of swift server

I will take a look to the discussion on the network API

Thanx

Gérard

···

Le 7 avr. 2017 à 22:52, Maxim Veksler <maxim@vekslers.org> a écrit :

Hi Gerald,

It might be only me I'm not sure what you are suggesting. I would agree that Swift Server could benefit greatly from an Actor Model framework, and Swift in general would probably benefit greatly from co-routines.

There is a Swift Server API's working group https://swift.org/server-apis/ it's for discussing lower level building blocks (network, HTTP, TLS) but is probably the most likely starting point for such discussions.

HTH.

On Sun, Apr 2, 2017 at 9:48 PM Gerard Iglesias via swift-users <swift-users@swift.org> wrote:
Hi,

I am working at the moment on a job which involves Scala and Akka, the kind of stuff which involve network, bid data, raw computing (Ai related) and scalability… Well buzz words of our time.

I would like to make the like in the swift world… Swift, GCD, Vapor or Perfect… To conduct some benchmark to compare the different approaches.

Do you see some other interesting technology worth to look at for this kind of things ?

Thank in advance.

Gerard
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Gerard Iglesias) #5

I was not aware .Net Core interesting ...

Kotlin on an other side, we have already Scala and my objective is to see on a real project how I can do the same with swift, not forced to have the same kind of technologies, but at the end able to deliver the same kind of capabilities and performances to the user.

For now Vapor is very nice regarding simplicity, capabilities on sever side... GCD for concurrent stuff.

And maybe implementing a simple kind of actor would be not so hard I believe. In fact the important thing with Actor and Akka is the implicit capability to send remote messages, it remind me the NeXT PDO capability.

We have the queue thing with GCD.

Regards

Gérard

···

Le 8 avr. 2017 à 18:26, Proyb P <proyb6@gmail.com> a écrit :

Yeah, I believe Gerard know that, he have been discussed in Vapor slack channel.

To add on, Gerard might want to try .Net core and Kotlin.

On Sat, Apr 8, 2017 at 4:52 AM, Maxim Veksler via swift-users <swift-users@swift.org> wrote:
Hi Gerald,

It might be only me I'm not sure what you are suggesting. I would agree that Swift Server could benefit greatly from an Actor Model framework, and Swift in general would probably benefit greatly from co-routines.

There is a Swift Server API's working group https://swift.org/server-apis/ it's for discussing lower level building blocks (network, HTTP, TLS) but is probably the most likely starting point for such discussions.

HTH.

On Sun, Apr 2, 2017 at 9:48 PM Gerard Iglesias via swift-users <swift-users@swift.org> wrote:
Hi,

I am working at the moment on a job which involves Scala and Akka, the kind of stuff which involve network, bid data, raw computing (Ai related) and scalability… Well buzz words of our time.

I would like to make the like in the swift world… Swift, GCD, Vapor or Perfect… To conduct some benchmark to compare the different approaches.

Do you see some other interesting technology worth to look at for this kind of things ?

Thank in advance.

Gerard
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Maxim Veksler) #6

For networking you could use something like
https://github.com/grpc/grpc-swift.

···

On Mon, Apr 10, 2017 at 8:22 PM Gerard Iglesias <gerard_iglesias@me.com> wrote:

I was not aware .Net Core interesting ...

Kotlin on an other side, we have already Scala and my objective is to see
on a real project how I can do the same with swift, not forced to have the
same kind of technologies, but at the end able to deliver the same kind of
capabilities and performances to the user.

For now Vapor is very nice regarding simplicity, capabilities on sever
side... GCD for concurrent stuff.

And maybe implementing a simple kind of actor would be not so hard I
believe. In fact the important thing with Actor and Akka is the implicit
capability to send remote messages, it remind me the NeXT PDO capability.

We have the queue thing with GCD.

Regards

Gérard

Le 8 avr. 2017 à 18:26, Proyb P <proyb6@gmail.com> a écrit :

Yeah, I believe Gerard know that, he have been discussed in Vapor slack
channel.

To add on, Gerard might want to try .Net core and Kotlin.

On Sat, Apr 8, 2017 at 4:52 AM, Maxim Veksler via swift-users < > swift-users@swift.org> wrote:

Hi Gerald,

It might be only me I'm not sure what you are suggesting. I would agree
that Swift Server could benefit greatly from an Actor Model framework, and
Swift in general would probably benefit greatly from co-routines.

There is a Swift Server API's working group https://swift.org/server-apis/ it's
for discussing lower level building blocks (network, HTTP, TLS) but is
probably the most likely starting point for such discussions.

HTH.

On Sun, Apr 2, 2017 at 9:48 PM Gerard Iglesias via swift-users < > swift-users@swift.org> wrote:

Hi,

I am working at the moment on a job which involves Scala and Akka, the
kind of stuff which involve network, bid data, raw computing (Ai related)
and scalability… Well buzz words of our time.

I would like to make the like in the swift world… Swift, GCD, Vapor or
Perfect… To conduct some benchmark to compare the different approaches.

Do you see some other interesting technology worth to look at for this
kind of things ?

Thank in advance.

Gerard
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


(Gerard Iglesias) #7

Thanx for the link on this…

I am experimenting the use of dispatch queue to mimic somme Actor Model things and it is not a bad idea, dispatch queue are perfect for that.

I wonder what is the scalability of the Dispatch layer, are we able to create a bunch of dispatch queue without putting the system on its knees ? I will do tests

Gerard

···

On 11 Apr 2017, at 00:49, Maxim Veksler <maxim@vekslers.org> wrote:

For networking you could use something like https://github.com/grpc/grpc-swift.

On Mon, Apr 10, 2017 at 8:22 PM Gerard Iglesias <gerard_iglesias@me.com <mailto:gerard_iglesias@me.com>> wrote:
I was not aware .Net Core interesting ...

Kotlin on an other side, we have already Scala and my objective is to see on a real project how I can do the same with swift, not forced to have the same kind of technologies, but at the end able to deliver the same kind of capabilities and performances to the user.

For now Vapor is very nice regarding simplicity, capabilities on sever side... GCD for concurrent stuff.

And maybe implementing a simple kind of actor would be not so hard I believe. In fact the important thing with Actor and Akka is the implicit capability to send remote messages, it remind me the NeXT PDO capability.

We have the queue thing with GCD.

Regards

Gérard

Le 8 avr. 2017 à 18:26, Proyb P <proyb6@gmail.com <mailto:proyb6@gmail.com>> a écrit :

Yeah, I believe Gerard know that, he have been discussed in Vapor slack channel.

To add on, Gerard might want to try .Net core and Kotlin.

On Sat, Apr 8, 2017 at 4:52 AM, Maxim Veksler via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
Hi Gerald,

It might be only me I'm not sure what you are suggesting. I would agree that Swift Server could benefit greatly from an Actor Model framework, and Swift in general would probably benefit greatly from co-routines.

There is a Swift Server API's working group https://swift.org/server-apis/ it's for discussing lower level building blocks (network, HTTP, TLS) but is probably the most likely starting point for such discussions.

HTH.

On Sun, Apr 2, 2017 at 9:48 PM Gerard Iglesias via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
Hi,

I am working at the moment on a job which involves Scala and Akka, the kind of stuff which involve network, bid data, raw computing (Ai related) and scalability… Well buzz words of our time.

I would like to make the like in the swift world… Swift, GCD, Vapor or Perfect… To conduct some benchmark to compare the different approaches.

Do you see some other interesting technology worth to look at for this kind of things ?

Thank in advance.

Gerard
_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org <mailto:swift-users@swift.org>
https://lists.swift.org/mailman/listinfo/swift-users


(Greg Parker) #8

Dispatch queues are intended to be cheap, comparable to a pthread_mutex IIRC.

The limited resource are the top-level global queues, DispatchQueue.main and DispatchQueue.global(…). There are a limited number of threads available to service concurrent items on those queues (around 500 threads on macOS and iOS, IIRC). If too many concurrent work items are pushed into the global queues at one time then the process may deadlock when dispatch exhausts its thread pool.

···

On Apr 11, 2017, at 9:10 AM, Gerard Iglesias via swift-users <swift-users@swift.org> wrote:

Thanx for the link on this…

I am experimenting the use of dispatch queue to mimic somme Actor Model things and it is not a bad idea, dispatch queue are perfect for that.

I wonder what is the scalability of the Dispatch layer, are we able to create a bunch of dispatch queue without putting the system on its knees ? I will do tests

--
Greg Parker gparker@apple.com <mailto:gparker@apple.com> Runtime Wrangler


(Alex Blewitt) #9

These can be accessed via sysctl, for future reference:

$ sysctl kern.wq_max_threads kern.wq_max_constrained_threads
kern.wq_max_threads: 512
kern.wq_max_constrained_threads: 64

The limit of 64 applies to lower-priority items (which is the default, IIRC) so you may find that you hit the 64 limit faster than you hit the 512 limit.

Alex

···

On 11 Apr 2017, at 23:37, Greg Parker via swift-users <swift-users@swift.org> wrote:

On Apr 11, 2017, at 9:10 AM, Gerard Iglesias via swift-users <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:

Thanx for the link on this…

I am experimenting the use of dispatch queue to mimic somme Actor Model things and it is not a bad idea, dispatch queue are perfect for that.

I wonder what is the scalability of the Dispatch layer, are we able to create a bunch of dispatch queue without putting the system on its knees ? I will do tests

Dispatch queues are intended to be cheap, comparable to a pthread_mutex IIRC.

The limited resource are the top-level global queues, DispatchQueue.main and DispatchQueue.global(…). There are a limited number of threads available to service concurrent items on those queues (around 500 threads on macOS and iOS, IIRC). If too many concurrent work items are pushed into the global queues at one time then the process may deadlock when dispatch exhausts its thread pool.