Hacker Newsnew | past | comments | ask | show | jobs | submit | __red__'s commentslogin

There's a whole lot of discussion below so I'm just going to tag from here.

I think of pony actors in the same way as I think of erlang actors. They have a "mailbox", and when they receive a message, they wake up, execute some amount of code, and then go back to sleep.

This is how I think about it. This is not how it is actually implemented.

Here's the key that I think many people miss about pony.

Referential Capabilities DO NOT EXIST at runtime.

So let's talk passing a String iso from Actor A, to Actor B. (iso is the capability that guarantees that this is the only reference to this object):

  // This is code in Actor A
  actorB.some_behaviour_call(consume myisostring)

The "consume myisostring" completely removes myisostring from Actor A. Any reference to it after this point will result in an "unknown variable myisostring" error from the compiler.

The reference to myisostring then gets sent to Actor B via its mailbox.

If ActorB was idle, then the message receive will cause Actor B to be scheduled and it will receive the reference to that String iso - completely isolated.

Now, if we're going to measure "performance of passing data between threads" as latency per transaction, then actor contention on a scheduler is going to be a bigger factor.

If you're measuring performance across an entire system with millions of these actions occurring, then I would argue that this approach would be faster as there is no spinning involved.


Pony schedulers default behaviour is as follows:

1. One scheduler per core. 2. Schedulers run one actor behaviour at a time. 3. When a scheduler has an empty work queue, they will steal work from other schedulers. 4. The number of schedulers will scale up and down with the amount of work (but never more than number of cores).

There are various parameters you can change to alter scheduler behaviour should your pattern of use need it.


This is alas the chicken and egg scenario and the most common reason I hear for people not wanting to invest the time in pony.

The vast majority of people I discuss it with understand the value and the problems it is designed to solve, but they either don't have domain-problems that require pony's approach more than any other language - or the lack of supporting libraries makes them nervous over adoption.

As a pony developer for 5+ years, it can be frustrating - but I do understand.


Pony is a strongly typed language. If you want your functions to return an Optional Type, define an Optional Type.

For example, the OpenFile API returns you either a valid pony File object, or why it failed (FileEOF, FileBadFileNumber, FileExists, FilePermissionDenied, etc…).

What partial functions do is ensure that all of the error cases are actively addressed by the programmer, so you don't get panics or SEGVs.


The problem is, what exactly do you do when your program hits a precondition or invariant violation?

There are basically only two possibilities: abort the process, or jump to a top-level handler that logs the error and returns a 500 response (or whatever the equivalent is, for a long-running program that's not a web server). In neither case is there any interesting decision to be made about how the direct caller should handle the error. In return, whenever you subscript an array or otherwise do anything that has preconditions or invariants, you have to add a question mark to every function that can transitively call it and every call site of same, throughout the codebase. This task requires no intelligence—it can be done algorithmically without error—so why require it?

If you could actually prevent precondition and invariant violations at compile time, that would be quite a different proposition, but Pony can't actually do that (because it requires dependent types) and the intermediate solution they've hit on appears to be the worst of all worlds.

Also, it seems perverse to have a syntax for calling fallible functions and propagating failures up the call stack, but then not allow it to be used for exceptional results, which are the kind of failure that's actually worth propagating up the call stack.


You can do this:

  try
    somearray(outofboundindex)?
    // stuff
  else
    errorlog.write("some message")
    error
  end
Sure you can make it propogate all the way up if you really want, but ugh… what a terrible idea for instrumentation.

Pony doesn't force you to deal with errors a specific way. Pony forces you to make a choice so you can't just ignore it.


That code is only allowed in a partial context, right? So if you don't propagate it all the way up the call stack, what do you do instead?


I'm not sure I understand what you mean by "real-time safe GC algorithms", but pony is not a language that has being a "real time system" as a design goal.

This pony paper here describes the pony GC algorithms and compares their performance under various scenarios to other language GCs.

https://www.ponylang.io/media/papers/orca_gc_and_type_system...

The charts you want to look at are on pages 19-21.

It shows that ORCA (pony's GC) has extremely low jitter and is highly performant compared to the other industry leaders at the time of publication.


Real-time safe GC algorithms and data structures provide strong guarantees that any interruptions to the running program caused by GC activity will have a bounded duration, with strong guarantees on the upper bound of any pause. This is important in latency sensitive software and real-time software that needs to meet deadlines.

Examples include IBM's Metronome: https://www.researchgate.net/publication/220829995_The_Metro... and https://developer.ibm.com/articles/garbage-collection-tradeo...

Thanks for the ORCA link. I'll have to study it more closely but from Fig 17 it looks to have quite unpredictable jitter up to at least 20ms. Which is obviously fine for many things but not useful for other things (e.g. processing AVB streaming audio packets at line rate every 125 us).

EDIT: I originally also cited the following, however I am not sure these were the papers that I was thinking of: Baker's algorithm: https://dspace.mit.edu/bitstream/handle/1721.1/41976/AI_WP_1... also discussed here: "Baker's garbage collector performs garbage collection in real time-- the elementary object creation and access operations take time which is bounded by a constant, regardless of the size of the memory." https://web.media.mit.edu/~lieber/Lieberary/GC/Realtime/Real...


It's less than a third of the others which are compared.

As with all things, we should use the correct language / runtime for the domain problems it's designed to solve.

The pony runtime makes other decisions (such as non-preemptable schedulers) which would have more of an effect on your use-case methinks.

Thank you for the discussion and your interest!


Thank you for the pointers, much appreciated.


It is not whitespace signficant.

That is indented to assist the human reader, not the compiler.


so you're telling me this is valid Pony?

actor Main

new create(env: Env) =>

TCPListener(TCPListenAuth(env.root), Listener(env.out))

??

If so, I don't want to every see that language in my life ever again.


So you like languages that treat whitespace as syntax.

That's fine, we all have our preferences :D


No? But Pony is clearly just like python in terms of whitespace?


TO be clear…

The switched because they changed their business focus from one of their products to another.

I'm sure we'd all agree that the best language to use is the language the best fits your problem domain.

Rust was a better fit for that new product than pony. That's not a reflection on the language.


I use pony https://ponylang.io/ as a language - it's an Actor based language with GC where every actor has its own memory and is responsible for its own GC.

The main feature is its ability to safely share or move data around between actors in a way that is data-race and deadlock free. Pony doesn't use locks anyways :-)

A high level as to how it achieves this:

i. All variables have a "reference capability" - which is a description of what you can and cannot do with the variable alias (pointer) you have.

ii. The references to the data (think pointer) are passed in messages.

iii. As references are made and removed, actors send messages to the originating actor updating the count of references. When the count reaches zero, that data can be GC'd.

It's nice, because unlike some other language runtimes, it doesn't have to stop the world to work out what can and can't be GC'd. It's all done on-the-fly as it were.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: