Skip to content

Conversation

@dcantah
Copy link
Contributor

@dcantah dcantah commented Sep 16, 2020

  • Add high level job object wrapper.
  • Add extra job object bindings for stats usage.

Signed-off-by: Daniel Canter [email protected]

@dcantah dcantah requested a review from a team as a code owner September 16, 2020 16:32
@dcantah
Copy link
Contributor Author

dcantah commented Oct 15, 2020

@kevpar @katiewasnothere @ambarve If anyone has time tomorrow, could you give this a glance

@dcantah dcantah force-pushed the jobwrapper branch 2 times, most recently from f8d9d8a to c398a8a Compare November 13, 2020 22:36
Copy link
Contributor

@ambarve ambarve left a comment

Choose a reason for hiding this comment

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

Added some comments.

for {
err := winapi.GetQueuedCompletionStatus(iocpHandle, &code, &key, (**windows.Overlapped)(unsafe.Pointer(&overlapped)), windows.INFINITE)
if err != nil {
log.G(ctx).WithError(err).Error("failed to poll for job object message")
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if this is some non-transient error i.e some error which won't be resolved by the time of next iteration? We will keep looping with no way of breaking out of the loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From asking around, I couldn't find such a case for this call so I didn't worry about it. In go-winio, we check if nothing was filled in for the overlapped struct and if not we just panic so I think this is a little more friendly at least.https://github.com/microsoft/go-winio/blob/5b44b70ab3ab4d291a7c1d28afe7b4afeced0ed4/file.go#L162

Copy link
Contributor

@ambarve ambarve Nov 20, 2020

Choose a reason for hiding this comment

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

That sounds fine. Do you think we should add a check for context Done()and break from this loop in that case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, that's a bad idea. The ctx which was actually used during a call to this function could be cancelled but then that will stop this loop for all other jobs.

Copy link

@katiewasnothere katiewasnothere left a comment

Choose a reason for hiding this comment

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

LGTM :)

mq.closed = true
// If there's anybody currently waiting on a value from ReadOrWait, we need to
// signal so the read can return ErrQueueClosed.
mq.c.Signal()
Copy link
Contributor

@ambarve ambarve Nov 20, 2020

Choose a reason for hiding this comment

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

I am still kind of confused about this. What happens if multiple goroutines call ReadOrWait() and are waiting for a notification to arrive but someone closes the queue before that. With the Signal call we will only wake one of them from the sleep right? Shouldn't all the goroutines wake up from their sleep and return ErrQueueEmpty?
We don't have any tests that tests this scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this should be broadcast, good call. For the write case it should just be signal but agreed here we should wake up everyone.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, for the write case we should only wake up one thread with a Signal call. Maybe I typed this comment near the write function in previous version and that caused the confusion. Haha.

@ambarve
Copy link
Contributor

ambarve commented Nov 20, 2020

One small fix about using Broadcast vs Signal but otherwise LGTM!

* Add high level job object wrapper.
* Add extra job object bindings for stats usage.

Signed-off-by: Daniel Canter <[email protected]>
@dcantah
Copy link
Contributor Author

dcantah commented Nov 20, 2020

@kevpar If you have some time to do a last sweep :)

@dcantah dcantah merged commit 53828ca into microsoft:master Dec 2, 2020
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.

4 participants