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

quiescence issue with actor pinning #4582

Closed
SeanTAllen opened this issue Jan 7, 2025 · 1 comment · Fixed by #4583
Closed

quiescence issue with actor pinning #4582

SeanTAllen opened this issue Jan 7, 2025 · 1 comment · Fixed by #4583
Labels
bug Something isn't working help wanted Extra attention is needed needs investigation This needs to be looked into before its "ready for work"

Comments

@SeanTAllen
Copy link
Member

The expectation when we merged actor pinning was that it worked the same for quiescence as a program without pinning. However that isn't the case at the moment. Given the quiescence rules, we would expect the following program to never end as the Main actor will always have a message in its queue.

use "actor_pinning"

actor Main
  let _env: Env
  let _auth: PinUnpinActorAuth

  new create(env: Env) =>
    _env = env
    _auth = PinUnpinActorAuth(env.root)
    ActorPinning.request_pin(_auth)
    check_pinned()

  be check_pinned() =>
    if ActorPinning.is_successfully_pinned(_auth) then
      do_stuff(10)
    else
      check_pinned()
    end

  be do_stuff(i: I32) =>
    do_stuff(i - 1)

  be done() =>
    ActorPinning.request_unpin(_auth)

However, the program does in fact exit.

With a slight tweak, it doesn't:

use "actor_pinning"

actor Main
  let _env: Env
  let _auth: PinUnpinActorAuth

  new create(env: Env) =>
    _env = env
    _auth = PinUnpinActorAuth(env.root)
    ActorPinning.request_pin(_auth)
    check_pinned()

  be check_pinned() =>
    if ActorPinning.is_successfully_pinned(_auth) then
      do_stuff(10)
    else
      check_pinned()
    end

  be do_stuff(i: I32) =>
    _env.out.print("Doing stuff: " + i.string())
    do_stuff(i - 1)

  be done() =>
    ActorPinning.request_unpin(_auth)

So long as regular scheduler threads have an actor that is busy, the program will continue to run. Here we introduced sending a message to the unpinned outstream actor and we continue to process.

This was brought to my attention by @redvers who was working with early actor pinning work from @dipinhora's branch and his programs were working great. When he switched to an official ponyc release, they would exit.

I did a bit of spelunking and as one might guess, this started happening before we merged. I did some testing and we start seeing this in commit 8c338ae aka "make pinned actor thread participate in CNF/ACK for termination".

@SeanTAllen SeanTAllen added help wanted Extra attention is needed bug Something isn't working needs investigation This needs to be looked into before its "ready for work" labels Jan 7, 2025
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Jan 7, 2025
@SeanTAllen
Copy link
Member Author

I assume from a draft being started at #4583 that @dipinhora is planning on looking at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed needs investigation This needs to be looked into before its "ready for work"
Projects
None yet
2 participants