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

[ESI Runtime] Read ports now invoke callbacks #7186

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

teqdruid
Copy link
Contributor

@teqdruid teqdruid commented Jun 15, 2024

We've switched from a polling 'pull' method to a callback-based 'push'
mechanism for read ports. Polling (via std::futures) is built on top of
the push mechanism.

The read-ordering problem has also been fixed by using std::futures
exclusively for polling schemes. They also allow for poll-wait-notify
schemes without any changes on our part.

@teqdruid teqdruid added the ESI label Jun 15, 2024
@teqdruid teqdruid force-pushed the teqdruid/esirt/func-ordering branch from 354970d to 2e8fac3 Compare June 15, 2024 22:54
@teqdruid teqdruid requested a review from mortbopet June 15, 2024 22:55
@teqdruid teqdruid marked this pull request as ready for review June 15, 2024 22:55
@teqdruid teqdruid force-pushed the teqdruid/esirt/func-ordering branch from 2e8fac3 to f1d632e Compare June 15, 2024 23:59
Copy link
Contributor

@mortbopet mortbopet left a comment

Choose a reason for hiding this comment

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

AFAICT this solves the multiple-readers problem, but doesn't solve the function service call problem.

The following code still does not guarantee that calls to a function is ordered wrt. the order of which the argument port was called

arg.write(argData);
return result.readAsync();

I.e. the following interleaving of two calls C1 and C2 is possible

C1 arg.write
C2 arg.write
C2 result.readAsync
C1 result.readAsync

So there must be a lock added to FuncService::Function::call to ensure that readAsync is always called for function call n before function call n+1 occurs.

@teqdruid
Copy link
Contributor Author

@mortbopet: if you're not blocked on this, I'm actually gonna finish the gRPC conversion first so that I don't have to screw around with the capnp backend to adapt it to the changes we discussed.

@teqdruid teqdruid marked this pull request as draft June 21, 2024 23:42
@teqdruid teqdruid force-pushed the teqdruid/esirt/func-ordering branch from f1d632e to 284f792 Compare June 22, 2024 04:55
@teqdruid teqdruid changed the title [ESI Runtime] Fix ordering problem with multiple reads [ESI Runtime] Read ports now invoke callbacks Jun 22, 2024
@teqdruid teqdruid force-pushed the teqdruid/esirt/func-ordering branch from 284f792 to 4bacb31 Compare June 22, 2024 05:21
We've switched from a polling 'pull' method to a callback-based 'push'
mechanism for read ports. Polling (via std::futures) is built on top of
the push mechanism.

The read-ordering problem has also been fixed by using std::futures
exclusively for polling schemes. They also allow for poll-wait-notify
schemes without any chances on our part.
@teqdruid teqdruid force-pushed the teqdruid/esirt/func-ordering branch from 4bacb31 to a975939 Compare June 22, 2024 05:51
@teqdruid teqdruid marked this pull request as ready for review June 22, 2024 05:51
@teqdruid
Copy link
Contributor Author

I think switching to callbacks made things more elegant.

@teqdruid teqdruid requested a review from mortbopet June 22, 2024 05:52
Comment on lines +67 to +68
ReadChannelPort(const Type *type) : ChannelPort(type) {}
virtual void disconnect() override { mode = Mode::Disconnected; }
Copy link
Contributor

Choose a reason for hiding this comment

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

With these split modes, and different modes having different member variables associated with them, i'd personally split those into two separate ReadChannelPort-derived classes to avoid any confusion/misuse/leak between the two API modes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is something I considered. The problem is that these channel ports are constructed when the system gets built from the manifest, not when the user locates them. So the user doesn't have the chance to specify the type before getting the reference to them.

@teqdruid teqdruid merged commit 34c73c3 into main Jun 24, 2024
4 checks passed
@teqdruid teqdruid deleted the teqdruid/esirt/func-ordering branch June 24, 2024 18:38
mingzheTerapines pushed a commit to Terapines/circt that referenced this pull request Jun 27, 2024
We've switched from a polling 'pull' method to a callback-based 'push'
mechanism for read ports. Polling (via std::futures) is built on top of
the push mechanism.

The read-ordering problem has also been fixed by using std::futures
exclusively for polling schemes. They also allow for poll-wait-notify
schemes without any changes on our part.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants