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

refactor(daemon): Coordinate host provideX implementations #2139

Merged
merged 2 commits into from
Mar 16, 2024

Conversation

rekmarks
Copy link
Contributor

@rekmarks rekmarks commented Mar 13, 2024

Progresses: #2086

coordinate, verb, "to combine in harmonious relation or action."

Synchronizes the host's provideWorker(). In addition, coordinates the implementations of the host's provideX methods such that they all:

  1. Attempt to get the existing formula id for the provided name, if any.
  2. If there is no existing formula id, incarnate and return a new value.

All type checks during step 1 have been removed. In other words, if you attempt to provide something under an existing name that resolves to a different value type, you're on your own. We may revisit this decision in the future.

packages/daemon/src/host.js Outdated Show resolved Hide resolved
@rekmarks rekmarks force-pushed the rekmarks-synchronize-provideWorker branch from 5f17afc to 8441d8d Compare March 13, 2024 22:26
@rekmarks rekmarks requested review from kriskowal and kumavis March 13, 2024 22:52
@rekmarks rekmarks force-pushed the rekmarks-synchronize-makeHost branch 2 times, most recently from 133ebdd to d91fa5b Compare March 14, 2024 18:41
Base automatically changed from rekmarks-synchronize-makeHost to master March 14, 2024 18:46
@rekmarks rekmarks force-pushed the rekmarks-synchronize-provideWorker branch from 8441d8d to f8dca9c Compare March 14, 2024 18:50
@rekmarks rekmarks marked this pull request as ready for review March 14, 2024 18:50
@rekmarks rekmarks marked this pull request as draft March 14, 2024 19:05
@rekmarks rekmarks force-pushed the rekmarks-synchronize-provideWorker branch 2 times, most recently from 9a3ce97 to 6d026a6 Compare March 14, 2024 22:24
@rekmarks rekmarks marked this pull request as ready for review March 14, 2024 22:24
@rekmarks rekmarks force-pushed the rekmarks-synchronize-provideWorker branch 3 times, most recently from 838a78f to 595e36b Compare March 15, 2024 23:17
@rekmarks rekmarks changed the title refactor(daemon): Synchronize provideWorker() refactor(daemon): Coordinate host provideX implementations Mar 15, 2024
@kriskowal
Copy link
Member

coordinate, verb, "to combine in harmonious relation or action."

and etymologically, “order with”.

Copy link
Member

@kriskowal kriskowal left a comment

Choose a reason for hiding this comment

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

I’m not entirely sold on the deferred tasks pattern but I’m going to take ownership of coming up with something better. Good to go!

packages/daemon/src/host.js Show resolved Hide resolved
tasks.push,
);
const workerFormulaIdentifier = tryGetWorkerFormulaIdentifier(workerName);
prepareWorkerIncarnation(workerName, workerFormulaIdentifier, tasks.push);
Copy link
Member

Choose a reason for hiding this comment

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

Apropos of naming, and entirely irrelevant to this PR…

Ain’t it weird that JavaScript inherits the deque methods from Perl:

front back
put unshift push
get shift pop

Whereas for a single ended queue, we still reach for French?

front back
put enqueue
get dequeue

AsyncQueue inherits get and put from priors.

I don’t think enqueue is wrong for serial jobs, but I’m not sure it’s the right word either.


Since you’re here, let me waste your time with this idea that’s been riding rent free in my hindbrain for at least ten years.

front back
put pish posh
get pip pop
peek tip top

Copy link
Contributor Author

Choose a reason for hiding this comment

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

💀

packages/daemon/src/host.js Show resolved Hide resolved
await E(host).provideWorker('foo');
await t.throwsAsync(() => E(host).evaluate('foo', '20', [], [], 'bar'), {
message:
'Cannot deliver "evaluate" to target; typeof target is "undefined"',
Copy link
Member

Choose a reason for hiding this comment

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

This is almost certainly a symptom of there being no entry in the worker weak map, or the internal facet for this formula being undefined anyway. I regret the internal/external separation and look forward to eliminating it.

@rekmarks rekmarks force-pushed the rekmarks-synchronize-provideWorker branch from 595e36b to 328c305 Compare March 16, 2024 03:45
coordinate, verb, "to combine in harmonious relation or action."

Refactors the host's `provideX()` methods such that they all:
1. Attempt to get the existing formula id for the provided name, if any.
2. If there is no existing formula id, incarnate and return a new value.

All type checks during step 1 have been removed. In other words, if you
attempt to provide something under an existing name that resolves to a
different value type, you're on your own. We may revisit this decision
in the future.
@rekmarks rekmarks force-pushed the rekmarks-synchronize-provideWorker branch from 328c305 to 7483103 Compare March 16, 2024 03:52
@rekmarks rekmarks merged commit fdc6989 into master Mar 16, 2024
18 checks passed
@rekmarks rekmarks deleted the rekmarks-synchronize-provideWorker branch March 16, 2024 03:58
rekmarks added a commit that referenced this pull request Mar 18, 2024
Fixes the provision of new (i.e. `NEW`) unnamed workers after #2139 broke
it. Adds a regression test for this case.
rekmarks added a commit that referenced this pull request Mar 18, 2024
Fixes the provision of new (i.e. `NEW`) unnamed workers after #2139 broke
it. Adds a regression test for this case.
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.

2 participants