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

Allow HPC-GAP to run as a forkable server process. #3715

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

rbehrends
Copy link
Contributor

This change is prompted by trying to make HPC-GAP work for Jupyter. Note that it changes the meaning of the -S command line option and therefore is labeled as WIP. I've put up the pull request so that people can test the functionality of Jupyter + HPC-GAP, even if details still needs to be settled. Note also that so far I've only tested this on macOS.

This commit includes the following changes:

  1. The Boehm GC is configured to properly handle fork().
  2. The -S command line option now starts HPC-GAP up in single-threaded
    mode without any other threads running.
  3. Normally, signals are handled by a separate thread; this is now being
    done in the function InstallHPCGAPSignalHandling. If started with
    -S, this function needs to be called explicitly in order to enable
    proper handling of SIGINT etc.

Please use the following template to submit a pull request, filling
in at least the "Text for release notes" and/or "Further details".
Thank You!

@rbehrends rbehrends added topic: HPC-GAP Issues and PRs related to HPC-GAP kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) kind: discussion discussions, questions, requests for comments, and so on labels Oct 24, 2019
olexandr-konovalov pushed a commit to OpenDreamKit/odk-review-hub that referenced this pull request Oct 24, 2019
@olexandr-konovalov
Copy link
Member

Thanks @rbehrends - this seems to work, we will do some further testing now.

@rbehrends
Copy link
Contributor Author

The one thing that I'm not happy with (yet) is that this basically requires starting the signal handler thread manually if run with -S. I'm thinking that maybe we need two different options to distinguish between "batch mode" and "server mode" ways of running without the console UI.

@olexandr-konovalov
Copy link
Member

@rbehrends maybe new command line option (-J for Jupyter?)

@coveralls
Copy link

coveralls commented Oct 24, 2019

Coverage Status

Coverage increased (+7.0e-05%) to 84.506% when pulling 2d354dd on rbehrends:hpcgap-server into ba30bd4 on gap-system:master.

@rbehrends
Copy link
Contributor Author

Something like this is what I'm thinking, except that this is only going to be used programmatically, so we don't have to waste a single letter command line option on it. Something like --single-thread or --server-mode?

@olexandr-konovalov
Copy link
Member

@rbehrends let's spare a single-letter option indeed, but both --single-thread or --server-mode could be equally confusing (e.g. understood as ways to disable threading completely, or to run an SCSCP server). What about --jupyter-mode? This will also be reusable outside HPC-GAP if we will discover that we need it later e.g. in GAP 4.12.

@rbehrends
Copy link
Contributor Author

The thing is that it's not really "Jupyter mode". What it does is it making sure that GAP starts up with only a single thread running. This is more of a fork-compatible mode. Jupyter is just one application for that.

@olexandr-konovalov
Copy link
Member

I see. And who knows, maybe for SCSCP package it will be useful as well. Anyhow, it serves the purpose for now, and we can use it next week, and think about a good option name in the meantime. Thanks again!

@rbehrends
Copy link
Contributor Author

I've added a --single-thread option and reverted the semantics of -S; the name is a placeholder for now, but with the logic in place, it can easily be renamed.

@olexandr-konovalov
Copy link
Member

@rbehrends thanks - then we will update our setup for Jupyter notebooks HPC-GAP demo.

minrk pushed a commit to OpenDreamKit/odk-review-hub that referenced this pull request Oct 25, 2019
olexandr-konovalov pushed a commit to OpenDreamKit/odk-review-hub that referenced this pull request Oct 26, 2019
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

In the PR description, you write that you changed the behavior of -S, but that doesn't really seem to be the case?

src/gap.c Outdated Show resolved Hide resolved
src/gap.c Outdated Show resolved Hide resolved
src/gap.c Outdated Show resolved Hide resolved
@rbehrends
Copy link
Contributor Author

@fingolfin See my comment above. I reverted the changes to -S in a later commit and introduced a separate command line option. I'll fix the formatting later tonight.

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

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

This actually looks good to me. Why exactly is this marked as WIP? Because the name of that command line option might be changed? Any other reason?

If @alex-konovalov and @stevelinton and @ChrisJefferson are happy with this PR, I am also happy to have it merged :-)

@rbehrends
Copy link
Contributor Author

Yeah, it's WIP because I basically just made up a name for the command line option and wanted to first check that this is fine with everyone.

@rbehrends
Copy link
Contributor Author

Also, another thing with --single-thread is that if you want signal handling, you need to do that after startup/forking by calling InstallHPCGAPSignalHandling(). This is currently not documented, nor is it clear whether we want that name or a more generic name like FinishHPCStartup() if we later need to put additional functionality in there.

@olexandr-konovalov
Copy link
Member

@rbehrends shall we merge this?

@rbehrends
Copy link
Contributor Author

If it's okay this way, I'll squash the commits, update the commit message, and then we can, yes.

This commit includes the following changes:

1. The Boehm GC is configured to properly handle fork().
2. The new --single-thread command line option now starts HPC-GAP up in
   single-threaded mode without any other threads running. This option
   implies -S (as the thread UI requires threads).
3. Normally, signals are handled by a separate thread; this is now being
   done in the function `InstallHPCGAPSignalHandling`. If started with
   --single-thread, this function needs to be called explicitly in order
   to enable proper handling of SIGINT etc.
@rbehrends
Copy link
Contributor Author

Update: I've squashed the commits as noted above, if the tests work, it can be merged.

@rbehrends rbehrends changed the title WIP: Allow HPC-GAP to run as a forkable server process. Allow HPC-GAP to run as a forkable server process. Nov 5, 2019
@rbehrends rbehrends removed the do not merge PRs which are not yet ready to be merged (e.g. submitted for discussion, or test results) label Nov 5, 2019
@olexandr-konovalov olexandr-konovalov added the release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes label Nov 6, 2019
@olexandr-konovalov olexandr-konovalov merged commit 0a82f2f into gap-system:master Nov 6, 2019
@olexandr-konovalov
Copy link
Member

@rbehrends thanks!

@fingolfin
Copy link
Member

Shall this be backported to 4.11?

@olexandr-konovalov
Copy link
Member

@fingolfin I think so!

@fingolfin
Copy link
Member

Backported to stable-4.11 in commit ac4b898

@fingolfin fingolfin added release notes: added PRs introducing changes that have since been mentioned in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Dec 5, 2019
@olexandr-konovalov olexandr-konovalov added this to the GAP 4.11.0 milestone Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-4.11-DONE kind: bug: crash Issues describing bugs that cause GAP to crash, and PRs fixing them (used for release notes) kind: discussion discussions, questions, requests for comments, and so on release notes: added PRs introducing changes that have since been mentioned in the release notes topic: HPC-GAP Issues and PRs related to HPC-GAP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants