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

Lparallel overhaul 2 #36

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

Lparallel overhaul 2 #36

wants to merge 42 commits into from

Conversation

Ambrevar
Copy link
Member

@Ambrevar Ambrevar commented Dec 18, 2023

Fixes #2 and supersedes #16, without input buffering.

I plan to add input buffering later (based on #16's work, or not).

This switches the whole thread management / concurrency logic from Calispel to Lparallel.

  • It simplifies the code a lot (about 100 lines less!).
  • It also makes it way less prone to race conditions, and much easier to debug.
  • Also less risk of dangling threads.
  • It works on ECL.
  • Update notifications now happen via hooks.

To do:

  • Update notifications are still awkward to use. See 917486a tests. They are not functional (the source object may be updated in parallel of the hook execution), and the hook may be run 2 or 3 times during each input update, which is counter-intuitive.
    I suggest to use 2 hooks:
    • One that is run in parallel at the very end.
    • Another one that is run like now, but in sync, thus guaranteeing the state of the source.
  • Once the above is fixed, update the README to mention the API breakages (e.g. with result, notifications, extra elements in attributes).

Thoughts?

@aadcg
Copy link
Member

aadcg commented Dec 18, 2023

  • It works on ECL.

This is a non-goal in my view, but a nice to have nonetheless.

Thoughts?

Sounds like a good plan. If I understood correctly, you're not request a review yet.

rosargs: [dynamic-space-size=3072]
os: [ubuntu-latest, macos-latest] # try windows-latest when we understand commands to install Roswell on it

# run the job on every combination of "lisp" and "os" above
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change goes beyond the scope of the PR, so I'd kindly ask to remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member Author

@Ambrevar Ambrevar Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changes thread management and one of the important features is to do it properly. This could be highlighted by the tests initially not working properly on ECL and macOS. Hence the need to restore the matrix to a wider state.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must be acknowledged that you find that an alternative CI design amounts to higher quality standards. I'd suggest having that exchange elsewhere (for instance, an issue). I consider that this PR is not the right context.

The current design of the CI was the product of thoughtful joint discussions with @jmercouris. Seeing a change of strategy without prior notice or discussion and within another context seems to lack some cordiality. I think we all have a vested interested in respecting each other's perspectives and reaching an amenable outcome for all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ambrevar can you please put it in another, separate PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in #37.

@jmercouris
Copy link
Member

Hello Pierre, a very welcome PR. I see many improvements. I am always glad to strip more dependencies from our tree.

One thing I am not understanding is the choice for a kernel per source, can you explain how/why?

Lastly, I wouldn't worry too much about breaking changes/dependents. How many people are using this library? We could query Quicklisp, and if nobody is using this library, then we needn't be strict about versioning information in my opinion.

@jmercouris
Copy link
Member

I also don't understand the purpose of notifications/hooks. Are they so that you can know when a particular source is done loading without blocking? Is it some sort of CSP code?

@Ambrevar
Copy link
Member Author

One thing I am not understanding is the choice for a kernel per source, can you explain how/why?

Quite simply: if two prompts are run in parallel (e.g. nested prompts), you want the computations to happen in parallel, i.e. you don't want a prompt to block another. Lastly, killing a kernel is a relatively clean and effective way to collect all its threads, and we can only do this if we have one kernel per prompt.

Lastly, I wouldn't worry too much about breaking changes/dependents.

It only costs a version bump and a short listing of the changes in the README. We do this for all our libraries and it's good practice, even to ourselves to remember the changes in the future.

I also don't understand the purpose of notifications/hooks. Are they so that you can know when a particular source is done loading without blocking? Is it some sort of CSP code?

Hooks are not CSP, they are just like Emacs hooks. The purpose is indeed to notify the caller when the source has changed. In practice, this is how Nyxt knows when to redraw.

@Ambrevar Ambrevar force-pushed the lparallel-overhaul2 branch from 472febd to e69eeec Compare December 22, 2023 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Switch to Lparallel and use conditions to cancel threads
3 participants