Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All the tutorials: we need motivating (advanced) examples in our docs #175

Open
1 of 4 tasks
Tracked by #339
goodboy opened this issue Dec 22, 2020 · 6 comments
Open
1 of 4 tasks
Tracked by #339
Assignees
Milestone

Comments

@goodboy
Copy link
Owner

goodboy commented Dec 22, 2020

Clearly, we need some fancier and more immediately practical examples in our readme (says every person who's glanced ever), so I figured I'd start list of what I think would be coolio.


A "worker pool" example copying concurrent.futures's prime number calculator


The multiprocessing.Pool examples:


A "controlled fork blast" example

  • this would be an example of creating a fork bomb out of nested nurseries which can be "controlled" via a SIGINT from the user once they've decided that enough CPU has been crushed; this demonstrates very succinctly the true power of SC.
  • we might want to monitor system resources for this test to avoid making it impossible to send input whatsoever

A real-time streaming sorting algorithm

  • I was thinking of implementing an async-ified version of pythonmaxmin which is based on the paper here
  • Another thing we might be able to show off is performing this sort on multiple streams in parallel and using a trio-ized version of an Rx merge to serialize results.

Target tutorial set:

this is the back of hand list I can think of:

  • basic spawning and actor lifetime management
  • nested actor trees and inter-actor rpc
  • basic streaming
  • advanced 2-way streaming
  • debugger usage
  • daemon structures and (micro)serivice design
  • fancy recipes and tractor.extras

Lurker opinions always welcome.

We might actually need to pick the best of these and then stick the rest in a parallelism tutorial.
Actually, we might want a streaming, shared state, and parallelism tutorial in the new docs.

@goodboy goodboy self-assigned this Dec 22, 2020
goodboy added a commit that referenced this issue Dec 23, 2020
This is a draft of the `tractor` way to implement the example from the
"processs pool" in the stdlib's `concurrent.futures` docs:

https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor-example

Our runtime is of course slower to startup but once up we of course get
the same performance, this confirms that we need to focus some effort
not on warm up and teardown times.  The mp forkserver method definitely
improves startup delay; rolling our own will likely be a good hot spot
to play with.

What's really nice is our implementation is done in approx 10th the code ;)

Also, do we want offer and interface that yields results as they arrive?

Relates to #175
goodboy added a commit that referenced this issue Dec 23, 2020
This is a draft of the `tractor` way to implement the example from the
"processs pool" in the stdlib's `concurrent.futures` docs:

https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor-example

Our runtime is of course slower to startup but once up we of course get
the same performance, this confirms that we need to focus some effort
not on warm up and teardown times.  The mp forkserver method definitely
improves startup delay; rolling our own will likely be a good hot spot
to play with.

What's really nice is our implementation is done in approx 10th the code ;)

Also, do we want offer and interface that yields results as they arrive?

Relates to #175
@parity3
Copy link

parity3 commented Jan 2, 2021

Wow, some of these, particularly the stream sorting may do well as their own separate repos/libraries!

Another possible example is to implement one of the function-as-a-service protocols with some tuning goodies.

@goodboy
Copy link
Owner Author

goodboy commented Jan 2, 2021

Another possible example is to implement one of the function-as-a-service protocols with some tuning goodies.

@parity3 sweet idea. I'd welcome a PR for something that too 😉

function-as-a-service

Also check #182, I think the caps based RPC is going to be here to stay the more I've thought about it.
I actually have been dreaming up auto-generating capn proto schema from python's type annotations.

@parity3
Copy link

parity3 commented Jan 2, 2021

Another piece of code that may be nice to see is for a tractor controller app to run as a daemon that some other sync or polyglot app could call into, and be used as a glorified task queue implementation. You could make it compatible with celery or dramatiq or whatever.

@goodboy
Copy link
Owner Author

goodboy commented Jan 2, 2021

You could make it compatible with celery

I was gonna say, IMO if you pair tractor with nanomessage or zeromq you can pretty much implement celery somewhat trivially, but it'll be rabbitmq free / tractor broker kinda thing.

That might be good further down the line to demonstrate how with the right primitives from the outset these specialized message pattern designs like celery (which AMQP is just a special case of something you can build with brokerless based scalability protocols and/or an actor model) are super easy to create without a giant slew of components / configuration.

This was kind of always the intention from the outset: make the zeromq of micro-service systems showing how most message oriented designs are just special cases if you start with the right primitives. This will be extended by theory around security principles from capability based sec and how you can build ultra-resilient supervisor trees with this approach.

@goodboy
Copy link
Owner Author

goodboy commented Jan 2, 2021

Hmm probably worth linking celery/ceps#27

@goodboy
Copy link
Owner Author

goodboy commented Jan 2, 2021

@parity3 yeah maybe a "micro-service design" tutorial is in order as well.

I think we'll end up picking the simplest / hippest of these examples and toss the rest in a "parallelism tutorial" in the docs.

goodboy added a commit that referenced this issue Jan 17, 2021
This is a draft of the `tractor` way to implement the example from the
"processs pool" in the stdlib's `concurrent.futures` docs:

https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor-example

Our runtime is of course slower to startup but once up we of course get
the same performance, this confirms that we need to focus some effort
not on warm up and teardown times.  The mp forkserver method definitely
improves startup delay; rolling our own will likely be a good hot spot
to play with.

What's really nice is our implementation is done in approx 10th the code ;)

Also, do we want offer and interface that yields results as they arrive?

Relates to #175
goodboy added a commit that referenced this issue Jan 24, 2021
This is a draft of the `tractor` way to implement the example from the
"processs pool" in the stdlib's `concurrent.futures` docs:

https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor-example

Our runtime is of course slower to startup but once up we of course get
the same performance, this confirms that we need to focus some effort
not on warm up and teardown times.  The mp forkserver method definitely
improves startup delay; rolling our own will likely be a good hot spot
to play with.

What's really nice is our implementation is done in approx 10th the code ;)

Also, do we want offer and interface that yields results as they arrive?

Relates to #175
goodboy added a commit that referenced this issue Jan 24, 2021
This is a draft of the `tractor` way to implement the example from the
"processs pool" in the stdlib's `concurrent.futures` docs:

https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor-example

Our runtime is of course slower to startup but once up we of course get
the same performance, this confirms that we need to focus some effort
not on warm up and teardown times.  The mp forkserver method definitely
improves startup delay; rolling our own will likely be a good hot spot
to play with.

What's really nice is our implementation is done in approx 10th the code ;)

Also, do we want offer and interface that yields results as they arrive?

Relates to #175
goodboy added a commit that referenced this issue Feb 21, 2021
This is a draft of the `tractor` way to implement the example from the
"processs pool" in the stdlib's `concurrent.futures` docs:

https://docs.python.org/3/library/concurrent.futures.html#processpoolexecutor-example

Our runtime is of course slower to startup but once up we of course get
the same performance, this confirms that we need to focus some effort
not on warm up and teardown times.  The mp forkserver method definitely
improves startup delay; rolling our own will likely be a good hot spot
to play with.

What's really nice is our implementation is done in approx 10th the code ;)

Also, do we want offer and interface that yields results as they arrive?

Relates to #175
@goodboy goodboy changed the title Motivating examples for the readme Motivating examples for the docs Feb 26, 2021
@goodboy goodboy added this to the Docs Revamp milestone Feb 26, 2021
@goodboy goodboy changed the title Motivating examples for the docs All the tutorials: we need motivating (advanced) examples in our docs Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants