Skip to content

quiche: implement SimpleLinkedHashMap platform APIs#6782

Merged
alyssawilk merged 35 commits intoenvoyproxy:masterfrom
danzh2010:spdy_arena
May 23, 2019
Merged

quiche: implement SimpleLinkedHashMap platform APIs#6782
alyssawilk merged 35 commits intoenvoyproxy:masterfrom
danzh2010:spdy_arena

Conversation

@danzh2010
Copy link
Copy Markdown
Contributor

@danzh2010 danzh2010 commented May 2, 2019

Add platform implementations for quiche::SimpleLinkedHashMap. And enable simple_linked_hash_map_test.cc.
Finish TODOs in quic|spdy_containsers_impl.h to implement Quic|SpdyLinkedHashMap with SimpleLinkedHashMap.
Add a few spdy build targets and test target: spdy_core_header_block_test which tests SpdyHeaderBlock which uses SimpleLinkedHashMap.
Update tar ball to 7bf7c3c358eb954e463bde14ea27444f4bd8ea05.

Risk Level: low, not used
Testing: enabled quiche tests: simple_linked_hash_map_test.cc and spdy_header_block_test.cc
Part of #2557

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>
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
Copy Markdown
Contributor Author

/assign @wu-bin

danzh1989 added 5 commits May 2, 2019 14:01
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>
Signed-off-by: Dan Zhang <danzh@google.com>
// TODO: implement
template <typename T> class QuicIntervalSetImpl;
template <typename Key, typename Value, int Size>
using QuicSmallMapImpl = std::unordered_map<Key, Value>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about absl::flat_hash_map, which is typically faster?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

deps = ["@envoy//source/extensions/quic_listeners/quiche/platform:spdy_platform_unsafe_arena_impl_lib"],
)

envoy_cc_library(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As we discussed offline, can you split this library into smaller ones, mirroring the internal libraries?

Copy link
Copy Markdown
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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG modulo a super small nit: Can we remove the "spdy" in the middle of the library name? i.e. change to "spdy_core_alt_svc_wire_format_lib". Same for "spdy_core_spdy_header_block_lib", "spdy_core_spdy_headers_handler_interface", "spdy_core_spdy_protocol_lib" and "spdy_core_spdy_test_utils_lib".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

)

envoy_cc_library(
name = "quiche_common_platform",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I'd prefer "quiche_platform", for similarity with (quic|spdy|http2)_platform.

Your call. (If you do change it to quiche_platform, please also change quiche_common_platform_test to quiche_platform_test, and quiche_common_platform_impl_lib to quiche_platform_impl_lib)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My concern is that if there are other directory added under quiche in the future, it will be hard to name those without specifying "common" here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM!

)

envoy_cc_test(
name = "quiche_spdy_core_test",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: For spdy test, please name it spdy_${something}_test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


// Similar to std::unordered_map, but with better performance and memory usage.
template <typename Key, typename Value, typename Hash>
using QuicheUnorderedMapImpl = absl::node_hash_map<Key, Value, Hash>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a particular reason to use absl::node_hash_map instead of absl::flat_hash_map?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

flat_hash_map doesn't support key stability. Since this impl will probably replace QuicUnorderedMap which is used in several places as replacement of std::unordered_map. It will take some extra effort to investigate if those places requires key stability or not to switch to absl::flat_hash_map. And as we use node_hash_map in upstream, it's better to use the same class here to make sure future upstream change can be smoothly imported.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM. In the long term we should probably rename it to QuicheNodeHashMap and add a QuicheFlatHashMap, or directly use the absl ones if that's allowed.

@@ -14,12 +20,7 @@
// TODO(mpw): fix includes to use full paths.
#include "spdy_string_impl.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This TODO seems easy to fix, can you do it while we are here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,10 @@
#pragma once
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file is already in test/extensions/..., which is correct since it's test only.
Can you remove this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah, yes, this is not supposed to be here.

danzh1989 added 3 commits May 6, 2019 15:18
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Copy link
Copy Markdown
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.

Looks great, just some nits on naming:)

copts = quiche_copt,
repository = "@envoy",
visibility = ["//visibility:public"],
deps = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: fold deps into a single line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


envoy_cc_library(
name = "spdy_core_spdy_header_block_lib",
srcs = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: fold "srcs" and "hdrs" into a single line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


envoy_cc_test_library(
name = "spdy_core_spdy_test_utils_lib",
srcs = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: fold "srcs" and "hdrs" into single lines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

)

envoy_cc_library(
name = "quiche_common_platform",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM!

)

envoy_cc_test(
name = "spdy_header_block_test",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Rename to spdy_core_header_block_test?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

deps = ["@envoy//source/extensions/quic_listeners/quiche/platform:spdy_platform_unsafe_arena_impl_lib"],
)

envoy_cc_library(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG modulo a super small nit: Can we remove the "spdy" in the middle of the library name? i.e. change to "spdy_core_alt_svc_wire_format_lib". Same for "spdy_core_spdy_header_block_lib", "spdy_core_spdy_headers_handler_interface", "spdy_core_spdy_protocol_lib" and "spdy_core_spdy_test_utils_lib".


// Similar to std::unordered_map, but with better performance and memory usage.
template <typename Key, typename Value, typename Hash>
using QuicheUnorderedMapImpl = absl::node_hash_map<Key, Value, Hash>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SGTM. In the long term we should probably rename it to QuicheNodeHashMap and add a QuicheFlatHashMap, or directly use the absl ones if that's allowed.

// consumed or referenced directly by other Envoy code. It serves purely as a
// porting layer for QUICHE.

#include "absl/hash/hash.h"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the two includes will be reordered if you run "fix_format".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, done

Signed-off-by: Dan Zhang <danzh@google.com>
wu-bin
wu-bin previously approved these changes May 7, 2019
Copy link
Copy Markdown
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.

Looks great to me. I took a look at the clang-tidy failure again, but still can't figure out why. @htuch @mpwarres : Any idea?

@htuch
Copy link
Copy Markdown
Member

htuch commented May 8, 2019

@wu-bin not sure; @lizan probably has a better idea. Random guesses include possibly missing Bazel deps or weird symlink interactions.

Signed-off-by: Dan Zhang <danzh@google.com>
danzh1989 added 2 commits May 8, 2019 17:17
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
Copy Markdown
Contributor Author

@lizan any idea about the clang_tidy failure?
bazel-out/k8-fastbuild/genfiles/external/com_googlesource_quiche/quiche/common/platform/api/quiche_logging.h:4:10: error: 'extensions/quic_listeners/quiche/platform/quiche_logging_impl.h' file not found [clang-diagnostic-error]
#include "extensions/quic_listeners/quiche/platform/quiche_logging_impl.h"
^

Apparently not missing files in deps, otherwise other ci would have failed.

"abseil_node_hash_map",
],
visibility = ["//visibility:public"],
deps = [":quic_platform_base_impl_lib"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add :quic_platform_logging_impl_lib to fix clang-tidy, bazel doesn't build header files only target explicitly but clang-tidy checks whether you added dependencies correctly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Woops, just realized another problem that quic_logging_impl.h is duplicated in both quic_platform_logging_impl_lib and quic_platform_base_impl_lib.

Fixed. Thanks for looking into this problem!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Still not fixed. This is really weird. Looking at the errors a few lines above:
Error while processing /source/source/extensions/quic_listeners/quiche/platform/quic_containers_impl.h.
10294 warnings and 1 error generated.
Error while processing /source/test/extensions/quic_listeners/quiche/platform/quiche_test_impl.h.
16998 warnings and 1 error generated.
Error while processing /source/source/extensions/quic_listeners/quiche/platform/quiche_logging_impl.h.
23702 warnings and 1 error generated.
Error while processing /source/source/extensions/quic_listeners/quiche/platform/quiche_logging_impl.cc.
31722 warnings and 1 error generated.
Error while processing /source/source/extensions/quic_listeners/quiche/platform/spdy_containers_impl.h.
37223 warnings and 1 error generated.
Error while processing /source/source/extensions/quic_listeners/quiche/platform/spdy_string_utils_impl.h.
39075 warnings and 1 error generated.
Error while processing /source/source/extensions/quic_listeners/quiche/platform/quiche_ptr_util_impl.h.
43844 warnings and 1 error generated.
Error while processing /source/source/extensions/quic_listeners/quiche/platform/quiche_unordered_containers_impl.h.
warning: do not reference any 'internal' namespaces; those implementation details are reserved to Abseil [abseil-no-internal-dependencies]
bazel-out/k8-fastbuild/genfiles/external/com_googlesource_quiche/quiche/common/platform/api/quiche_logging.h:4:10: error: 'extensions/quic_listeners/quiche/platform/quiche_logging_impl.h' file not found [clang-diagnostic-error]
#include "extensions/quic_listeners/quiche/platform/quiche_logging_impl.h"

The file path is /source/source/extensions/quic_listeners/quiche/platform/... or /source/test/extensions/quic_listeners/quiche/platform/.... There is a /source added to the actual file path.

Why would clang_tidy CI do that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CI image checkout repository to /source so the path is correct.

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

/assign @mattklein123

Signed-off-by: Dan Zhang <danzh@google.com>
danzh1989 added 3 commits May 17, 2019 15:49
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
danzh1989 added 7 commits May 20, 2019 12:15
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>
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
Copy Markdown
Contributor Author

previous clang_tidy failure was caused by a circular dependency. Fixed now. PTAL

Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

lgtm modulo one nit

// #include "extensions/quic_listeners/quiche/platform/spdy_string_impl.h"
// #include "extensions/quic_listeners/quiche/platform/spdy_string_piece_impl.h"
//
// However, for some reason, bazel.clang_tidy cannot resolve the files when specified this way.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this part of the comment be removed as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes, they should. Done.

danzh1989 added 2 commits May 21, 2019 16:59
Signed-off-by: Dan Zhang <danzh@google.com>
Signed-off-by: Dan Zhang <danzh@google.com>
@alyssawilk alyssawilk merged commit d3e35b6 into envoyproxy:master May 23, 2019
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.

7 participants