Replace LogicalThread with WorkSerializer#21846
Conversation
7ffc0eb to
6e85015
Compare
6e85015 to
7430988
Compare
markdroth
left a comment
There was a problem hiding this comment.
This looks really good! All my comments are minor.
Please let me know if you have any questions about any of this.
Reviewed 21 of 21 files at r1.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @yashykt)
src/core/lib/iomgr/work_serializer.h, line 35 at r1 (raw file):
namespace grpc_core { extern DebugOnlyTraceFlag grpc_work_serializer_trace;
Is this needed anywhere outside of the .cc file? If not, let's remove it from here.
src/core/lib/iomgr/work_serializer.h, line 37 at r1 (raw file):
extern DebugOnlyTraceFlag grpc_work_serializer_trace; class WorkSerializerImpl : public Orphanable {
Can we move this into the .cc file, so it's not in the header at all? If you run into problems whereby the OrphanablePtr<> dtor needs to know the definition of WorkSerializerImpl, you might be able to work around them by declaring a dtor for WorkSerializer and defining it in the .cc file (even if it's just an empty function).
If that won't work for some reason, let's at least make WorkSerializerImpl a private member of WorkSerializer.
src/core/lib/iomgr/work_serializer.h, line 55 at r1 (raw file):
// WorkSerializer is a mechanism to schedule callbacks in a synchronized manner. // All callbacks scheduled on a WorkSerializer instance will be executed // serially in a borrowed thread. The API provides a FIFO guarantee to the
I think this documentation should explicitly point out the following things:
- The borrowed threads are the ones that call
Run(). - When you call
Run(), your callback might run directly inline, or it might run in a different thread that is already inside ofRun(). If your callback runs directly inline, other callbacks from other threads might also run inline beforeRun()returns. - Because an arbitrary set of callback might run directly inline, you should generally not hold any locks while calling
Run().
src/core/lib/iomgr/work_serializer.h, line 59 at r1 (raw file):
class WorkSerializer { public: WorkSerializer() { impl_ = MakeOrphanable<WorkSerializerImpl>(); }
impl_ can be initialized in an initializer list instead of in the ctor body.
src/core/lib/iomgr/work_serializer.cc, line 105 at r1 (raw file):
return; } // There is atleast one callback on the queue. Pop the callback from the
s/atleast/at least/
yashykt
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @markdroth)
src/core/lib/iomgr/work_serializer.h, line 35 at r1 (raw file):
Previously, markdroth (Mark D. Roth) wrote…
Is this needed anywhere outside of the .cc file? If not, let's remove it from here.
Done.
src/core/lib/iomgr/work_serializer.h, line 37 at r1 (raw file):
Previously, markdroth (Mark D. Roth) wrote…
Can we move this into the .cc file, so it's not in the header at all? If you run into problems whereby the
OrphanablePtr<>dtor needs to know the definition ofWorkSerializerImpl, you might be able to work around them by declaring a dtor forWorkSerializerand defining it in the .cc file (even if it's just an empty function).If that won't work for some reason, let's at least make
WorkSerializerImpla private member ofWorkSerializer.
Ah! That's a smart way! Worked!
src/core/lib/iomgr/work_serializer.h, line 55 at r1 (raw file):
Previously, markdroth (Mark D. Roth) wrote…
I think this documentation should explicitly point out the following things:
- The borrowed threads are the ones that call
Run().- When you call
Run(), your callback might run directly inline, or it might run in a different thread that is already inside ofRun(). If your callback runs directly inline, other callbacks from other threads might also run inline beforeRun()returns.- Because an arbitrary set of callback might run directly inline, you should generally not hold any locks while calling
Run().
Done.
src/core/lib/iomgr/work_serializer.h, line 59 at r1 (raw file):
Previously, markdroth (Mark D. Roth) wrote…
impl_can be initialized in an initializer list instead of in the ctor body.
Done.
src/core/lib/iomgr/work_serializer.cc, line 105 at r1 (raw file):
Previously, markdroth (Mark D. Roth) wrote…
s/atleast/at least/
Done.
yashykt
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @markdroth)
src/core/lib/iomgr/work_serializer.h, line 37 at r1 (raw file):
Previously, yashykt (Yash Tibrewal) wrote…
Ah! That's a smart way! Worked!
Done.
markdroth
left a comment
There was a problem hiding this comment.
Just one more small change needed here.
Thanks for doing this!
Reviewed 2 of 2 files at r2.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @yashykt)
src/core/lib/iomgr/work_serializer.h, line 36 at r2 (raw file):
namespace grpc_core { class WorkSerializerImpl;
Please make this declaration a private member of WorkSerializer.
yashykt
left a comment
There was a problem hiding this comment.
Reviewable status: 19 of 21 files reviewed, 1 unresolved discussion (waiting on @markdroth)
src/core/lib/iomgr/work_serializer.h, line 36 at r2 (raw file):
Previously, markdroth (Mark D. Roth) wrote…
Please make this declaration a private member of
WorkSerializer.
Done.
markdroth
left a comment
There was a problem hiding this comment.
Looks great!
Reviewed 2 of 2 files at r3.
Reviewable status:complete! all files reviewed, all discussions resolved
|
Thanks for reviewing! |
(Forked from #21361)
This change is