Skip to content

no synchronisation mechanism needed for portfolio workers#840

Merged
quickbeam123 merged 3 commits intomasterfrom
michael-no-portfolio-sync
Apr 21, 2026
Merged

no synchronisation mechanism needed for portfolio workers#840
quickbeam123 merged 3 commits intomasterfrom
michael-no-portfolio-sync

Conversation

@MichaelRawson
Copy link
Copy Markdown
Contributor

At some point portfolio workers were synchronised with UNIX semaphores to prevent them trampling over a valid proof.

In #540 I changed this mechanism to a more portable version based on files, but we can do better: just don't synchronise at all, have each child process write to their own temporary file, and have the parent process print the proof.

Closes #548.

Comment thread CASC/PortfolioMode.cpp Outdated
if(!_numWorkers)
{
if(!_numWorkers) {
// TODO this has been around since the ark, is it still worth the weirdness?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

10/10 todo. 😄

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is not as weird as it sounds.

It only kicks in if the user explicitly sets --cores 0 which says "give me all" and it gives you less than "all" if you have plenty (i.e. on a server).

Still, open to discussion. At the very least, I can add a comment explaining the semantics...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, OK - and this is desirable on a server, I guess. Comment would be great if you're already looking! Otherwise I can do it.

Comment thread CASC/PortfolioMode.cpp
Copy link
Copy Markdown
Contributor

@mezpusz mezpusz left a comment

Choose a reason for hiding this comment

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

Seems like a nice simplification.

@quickbeam123 quickbeam123 force-pushed the michael-no-portfolio-sync branch from 5c6b02c to 3e6e8d1 Compare April 20, 2026 14:45
Comment thread CASC/PortfolioMode.cpp Outdated

return result;
// done with the temporary file now
fs::remove(path);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@quickbeam123 this was what I had in mind for removing at least the proof that was printed. Works on my machine. ;-) Let me investigate a bit...

@MichaelRawson MichaelRawson force-pushed the michael-no-portfolio-sync branch from a5f41a7 to 2150406 Compare April 21, 2026 12:11
@MichaelRawson MichaelRawson force-pushed the michael-no-portfolio-sync branch from 2150406 to 6cc35c5 Compare April 21, 2026 12:13
@quickbeam123 quickbeam123 merged commit 9034d93 into master Apr 21, 2026
1 check passed
@quickbeam123 quickbeam123 deleted the michael-no-portfolio-sync branch April 21, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

don't synchronise proofs if we don't print them

3 participants