Skip to content

quiche:remove setThreadFactory() from QuicThreadImpl#6700

Merged
mattklein123 merged 10 commits intoenvoyproxy:masterfrom
danzh2010:quicthread
Apr 26, 2019
Merged

quiche:remove setThreadFactory() from QuicThreadImpl#6700
mattklein123 merged 10 commits intoenvoyproxy:masterfrom
danzh2010:quicthread

Conversation

@danzh2010
Copy link
Contributor

QuicThreadImpl is initialized within QUIC tests defined in QUICHE, it doesn't call upon setThreadFactory() added by #6658 while creating thread. This PR makes QuicThreadImpl itself to provide a 'singleton' Envoy::PlatformImpl instance so that the interface of QuicThreadImpl can be as desired by QUICHE.

Risk Level: low, not in use
Testing: covered by existing test

Part of #2557

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

/assign @mattklein123 @wu-bin
First trial to resolve discussion in #6658 (comment) to see if people like this approach.

Copy link
Contributor

@wu-bin wu-bin left a comment

Choose a reason for hiding this comment

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

Did you forget to commit quic_thread_impl.cc?

Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

Did you forget to commit quic_thread_impl.cc?

Yes, sorry for missing it.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, 1 question:

/wait-any

#include "exe/platform_impl.h"

Envoy::Thread::ThreadFactory* getThreadFactory() {
static Envoy::PlatformImpl* platform_impl = new Envoy::PlatformImpl();
Copy link
Member

Choose a reason for hiding this comment

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

cc @jmarantz I haven't been tracking the entire convo here, but don't we want to avoid potentially having multiple platform instances in the process? I thought we were considering some type of init() function that the QUICHE platform layer could use to then store static references if needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is test-only code, right? Can it be moved to test/extensions/quic_listeners/quiche/platform along with all the other code that depends on it?

Then you can just use Thread::threadFactoryForTest() which is defined in test/test_common/thread_factory_for_test.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I moved it to /test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cc @jmarantz I haven't been tracking the entire convo here, but don't we want to avoid potentially having multiple platform instances in the process? I thought we were considering some type of init() function that the QUICHE platform layer could use to then store static references if needed?

Where to inject such init() function then? QUICHE has its own self-sufficient tests. The only place I could think of is overload testing::main, but not sure how much plumbing it would require.

Copy link
Contributor

Choose a reason for hiding this comment

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

My thinking after that last discussion on #6658 was that no init() is necessary as Quic only needs singleton access to the ThreadFactory in tests, and we already have a mechanism for that.

Copy link
Member

Choose a reason for hiding this comment

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

If it's just tests, we can do what @jmarantz proposes. If it's in production code, I think an initialize function called from main after the platform is ready should be fine?

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
jmarantz
jmarantz previously approved these changes Apr 24, 2019
Copy link
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

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

basically looks good modulo one nit.

public:
QuicThreadImpl(const std::string& /*name*/) {}
QuicThreadImpl(const std::string& /*name*/) {
thread_factory_ = &Envoy::Thread::threadFactoryForTest();
Copy link
Contributor

Choose a reason for hiding this comment

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

make thread_factory_ a reference and init in the initializer, per Envoy convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

I refreshed a few times but this still doesn't look done to me; maybe this a github glitch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change in the wrong branch. Now done in real.


cc_library(
name = "quic_platform_port_utils",
name = "quic_platform_for_test",
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is incompatible with my #6693. Can you add a new library instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify: QuicThread is test-only, but quic_port_utils.h is used in production so we need to split them, right? SGTM.

Copy link
Contributor

Choose a reason for hiding this comment

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

quic_port_utils.h is also test-only, the problem is that I'm trying to use smaller libraries in #6693 and this PR is doing the opposite:)

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just make sure that goes in first then?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jmarantz: Yes, I'd prefer for that to go in first:) I just assigned it to you:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split into small libraries. This PR is blocking #6650. I hope to check in this one ASAP.

Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@danzh2010
Copy link
Contributor Author

sync'ed with #6693. PTAL

@danzh2010 danzh2010 changed the title remove setThreadFactory() from QuicThreadImpl quiche:remove setThreadFactory() from QuicThreadImpl Apr 25, 2019
mattklein123
mattklein123 previously approved these changes Apr 25, 2019
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Nice

@mattklein123 mattklein123 dismissed their stale review April 26, 2019 03:56

one more change needed

Signed-off-by: Dan Zhang <danzh@google.com>
@mattklein123 mattklein123 merged commit ca28063 into envoyproxy:master Apr 26, 2019
jeffpiazza-google pushed a commit to jeffpiazza-google/envoy that referenced this pull request Apr 26, 2019
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Jeff Piazza <jeffpiazza@google.com>
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.

5 participants