Skip to content

Use the rc package for refcounting inside the implementation of Client. #515

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

Merged
merged 32 commits into from
May 25, 2023

Conversation

zenhack
Copy link
Contributor

@zenhack zenhack commented May 11, 2023

This builds on top of #502, #508, and #509. There are still some failing tests, so I'm marking this as a draft, but it's close enough that it's probably worth a look.

zenhack added 19 commits April 27, 2023 00:14
This makes the implementation of Promise.Resolve a bit cleaner.
...called clientCursor. Step 1 in a broader refactoring.
We now use the rc package. There are some test failures that need to be
pinned down.
Tests seem to expect this to still be good.
With an initially null Client, the client pointer is nil so this field
doesn't even exist.
This fixes a number of tests, but not all of them.
We no longer have a bunch of call sites that need to do other things
with the locked value, so let's just acquire it inside the function and
simplify the heck out of how this is used.
...as well as naming it as such; there's no other misc. clientHookState
data, it's all promise resolution.
...just inline it into compress; there's no other logic in there anyway.
@zenhack zenhack requested a review from lthibault May 11, 2023 22:28
@zenhack zenhack marked this pull request as draft May 11, 2023 22:28
lthibault
lthibault previously approved these changes May 11, 2023
Copy link
Collaborator

@lthibault lthibault left a comment

Choose a reason for hiding this comment

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

Okay, actually reviewed for real this time. LGTM overall, but requesting a small clarification.

zenhack added 3 commits May 13, 2023 20:20
...which isn't entirely trivial.
We always pass this around in a mutex anyway, so just move that inside
the struct like everything else that has synchronized state.
@zenhack
Copy link
Contributor Author

zenhack commented May 14, 2023

Trying to record outstanding issues:

  • The semantics around weakrefs are different. This is actually a bit challenging to fix, and per discussion on matrix, it's not entirely clear that we care -- but at a minimum there is a test in the main package that will need fixing.
  • There seems to be a new bug that results in leaking the clients created by a promise in recvCap, specifically for receiverAnswer.
  • TestDuplicateBootstrap fails intermittently. It seems the weakref in the import table entry is being dropped between returns, so the two clients end up with separate importClients, though they point to the same place. I'm not sure why this is happening; it's tempting to think it must be related to the other weakrefs thing, but I don't think the change in semantics actually explains it.

@zenhack
Copy link
Contributor Author

zenhack commented May 16, 2023

Fixed the client leak.

zenhack added 2 commits May 15, 2023 20:21
Fixes a leak. I'm not sure why this worked before the rc refactor.
@zenhack
Copy link
Contributor Author

zenhack commented May 24, 2023

I went ahead and updated the weakrefs test. I'm still a little stumped on TestDuplicateBootstrap, and am getting frustrated. I'm tempted to suggest merging this with the failure in place (maybe marking the test as flaky); the bug seems less serious than the one we're on track to fix, so maybe punt it until later.

zenhack added 2 commits May 23, 2023 21:34
Per some discussion on matrix, the way weakrefs interact with promise
resolution has changed, but I don't think we actually care, so this
just changes the test to match.
@zenhack zenhack marked this pull request as ready for review May 24, 2023 23:16
@zenhack zenhack requested a review from lthibault May 24, 2023 23:16
As Louis pointed out, this is a bit weird, and I'm not sure why I
changed it.
@zenhack zenhack merged commit 2ad05d6 into capnproto:main May 25, 2023
@zenhack zenhack deleted the rc-pkg branch May 25, 2023 16:39
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