Load data store for server-side load reporting#14793
Conversation
|
|
7541032 to
67b550c
Compare
|
1 similar comment
|
|
1 similar comment
|
|
|
|
This looks like a good start. Please let me know if you have any questions about anything. We should probably also have someone from grpclb-team review this. Reviewed 5 of 16 files at r1, 11 of 11 files at r2, 5 of 5 files at r3. build.yaml, line 1880 at r3 (raw file):
These targets also need to be added to the BUILD files. src/cpp/server/load_reporter/load_data_store.h, line 31 at r2 (raw file):
Please document all classes and all non-trivial methods. It might also be useful to have a top-level comment here explaining the high-level structure here (i.e., identify all data structures and their relationships to each other). src/cpp/server/load_reporter/load_data_store.h, line 50 at r2 (raw file):
This name is much too generic for the src/cpp/server/load_reporter/load_data_store.h, line 87 at r2 (raw file):
Please avoid using src/cpp/server/load_reporter/load_data_store.h, line 94 at r2 (raw file):
Same as above: this name is too generic for this namespace. src/cpp/server/load_reporter/load_data_store.h, line 135 at r2 (raw file):
Nit: This can be merged with the string on the previous line. src/cpp/server/load_reporter/load_data_store.h, line 221 at r2 (raw file):
Why is this needed? Can't we just make the methods used by src/cpp/server/load_reporter/load_data_store.h, line 233 at r2 (raw file):
How about making the value a src/cpp/server/load_reporter/load_data_store.cc, line 70 at r2 (raw file):
When using Same thing throughout this PR. src/cpp/server/load_reporter/load_data_store.cc, line 70 at r2 (raw file):
Note that the type of I generally just use Same thing throughout this PR. src/cpp/server/load_reporter/load_reporter.h, line 35 at r2 (raw file):
We should not have src/cpp/server/load_reporter/load_reporter.h, line 74 at r2 (raw file):
If it takes ownership, how about changing the parameters to be src/cpp/server/load_reporter/load_reporter.h, line 106 at r2 (raw file):
No need for the src/cpp/server/load_reporter/load_reporter.h, line 107 at r2 (raw file):
Struct members, unlike class members, should not have an underscore suffix. src/cpp/server/load_reporter/load_reporter.h, line 134 at r2 (raw file):
Do we have any idea what kind of traffic we'll be seeing here? It might be useful to try to get an idea of how performant this actually needs to be, since that may influence the design. src/cpp/server/load_reporter/load_reporter.cc, line 30 at r2 (raw file):
This will only work on Linux. What will we do on (e.g.) MacOS or Windows? src/cpp/server/load_reporter/load_reporter_async_service_impl.h, line 31 at r2 (raw file):
Constant names should be of the form described here: src/cpp/server/load_reporter/load_reporter_async_service_impl.h, line 33 at r2 (raw file):
How about using the gRPC version number instead? src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 25 at r2 (raw file):
Any reason not to just do this? src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 33 at r2 (raw file):
This is disallowed by the style guide: A simple work-around is to make the static variable a pointer, set it to point to an instance allocated via src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 67 at r2 (raw file):
This shouldn't be deciding on the port itself or encapsulating the @yang-g may be able to help you figure out how to structure this. I know that we have a bunch of services that get automatically added internally (e.g., reflection, health-checking, etc), but I don't know if we're currently doing anything like that in OSS. src/cpp/server/load_reporter/util.h, line 30 at r2 (raw file):
For all of the functions in this file, it seems like it would be more efficient to replace src/cpp/server/load_reporter/util.h, line 43 at r2 (raw file):
This seems fairly inefficient, although it may be fine if it's not used often. If this does get used a lot, and if you take my suggestion above about using src/proto/grpc/lb/v1/load_reporter.proto, line 23 at r2 (raw file):
This looks like a duplicate of the well-known google.protobuf.Duration proto. Instead of defining that again here, please change this to depend on that proto. Note that @ncteisen recently did something like this for the channelz proto, so he can probably help you iron out any build dependency issues. src/proto/grpc/lb/v1/load_reporter.proto, line 96 at r2 (raw file):
The last sentence of this comment does not apply to OSS and should be removed. test/cpp/server/load_reporter/load_data_store_test.cc, line 36 at r2 (raw file):
Same comment about const naming as I mentioned in one of the other files. test/cpp/server/load_reporter/load_data_store_test.cc, line 36 at r3 (raw file):
We're not supposed to have global variables of non-POD type, as I mentioned elsewhere. Comments from Reviewable |
|
|
|
|
Thanks for reviewing! @summerxyt @slash-lib, please take a look at the logic around load data. This PR is WIP regarding the Census part. Review status: all files reviewed at latest revision, 27 unresolved discussions, some commit checks broke. build.yaml, line 1880 at r3 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_data_store.h, line 31 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_data_store.h, line 50 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Both done. src/cpp/server/load_reporter/load_data_store.h, line 87 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_data_store.h, line 94 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_data_store.h, line 135 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_data_store.h, line 221 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Upon further thought, I should remove the friend class and add some public methods for the searching. src/cpp/server/load_reporter/load_data_store.h, line 233 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. I've converted all the relevant usage about those two member variables to src/cpp/server/load_reporter/load_data_store.cc, line 70 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_data_store.cc, line 70 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. Good catch! I've shortened the name of some loop variables unless the loop body is long or complex. src/cpp/server/load_reporter/load_reporter.h, line 35 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Removed. Thanks for pointing this out; I didn't realize that before. Also changed some declarations to use src/cpp/server/load_reporter/load_reporter.h, line 74 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_reporter.h, line 106 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_reporter.h, line 107 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_reporter.h, line 134 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
@slash-lib @summerxyt may have more context about this. src/cpp/server/load_reporter/load_reporter.cc, line 30 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. Sorry, I should've added a TODO here. src/cpp/server/load_reporter/load_reporter_async_service_impl.h, line 31 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. src/cpp/server/load_reporter/load_reporter_async_service_impl.h, line 33 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
In the protobuf file, src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 25 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
It can't compile with src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 33 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. So I also changed src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 67 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Looks like src/cpp/server/load_reporter/util.h, line 30 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. Yes, the structure is clearer by using I think a strong argument to use src/cpp/server/load_reporter/util.h, line 43 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. I guess iterator view means iterating all the keys and storing all of them? src/proto/grpc/lb/v1/load_reporter.proto, line 23 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. Will update src/proto/grpc/lb/v1/load_reporter.proto, line 96 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. Sorry about that. test/cpp/server/load_reporter/load_data_store_test.cc, line 36 at r2 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. test/cpp/server/load_reporter/load_data_store_test.cc, line 36 at r3 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. Moved to test suite class. The style guide does specify how to name constants and class member variables, but doesn't specify how to name const class members. I keep the name style of constants because we originally want some constants, and we make them class member variables because of other restriction. Comments from Reviewable |
|
|
This is moving in the right direction. Please let me know if you have any questions. Reviewed 2 of 5 files at r4, 10 of 10 files at r5. src/cpp/server/load_reporter/load_data_store.h, line 233 at r2 (raw file): Previously, AspirinSJL (Juanli Shen) wrote…
Well, The style guide discourages use of There's even more detailed guidance about this in the internal style guide. In general, I think Is there a reasonable way to avoid using src/cpp/server/load_reporter/load_data_store.h, line 125 at r5 (raw file):
I think it would be easier to understand and slightly more efficient to say this: This approach avoids instantiating a src/cpp/server/load_reporter/load_data_store.h, line 200 at r5 (raw file):
How about adding a typedef for this, so we don't have to repeat it twice? src/cpp/server/load_reporter/load_data_store.h, line 200 at r5 (raw file):
Methods should not return non- src/cpp/server/load_reporter/load_data_store.cc, line 33 at r5 (raw file):
src/cpp/server/load_reporter/load_data_store.cc, line 101 at r5 (raw file):
Instead of using src/cpp/server/load_reporter/load_data_store.cc, line 103 at r5 (raw file):
Using the This avoids creating a temporary set to hold the candidates. src/cpp/server/load_reporter/load_data_store.cc, line 118 at r5 (raw file):
I think this can be done without instantiating an unnecessary vector by using src/cpp/server/load_reporter/load_data_store.cc, line 133 at r5 (raw file):
Instead of constructing a new set to return, I suggest having this return a pointer to the original set, which can be null if src/cpp/server/load_reporter/load_data_store.cc, line 145 at r5 (raw file):
If we stick with src/cpp/server/load_reporter/load_data_store.cc, line 159 at r5 (raw file):
src/cpp/server/load_reporter/load_data_store.cc, line 164 at r5 (raw file):
Use src/cpp/server/load_reporter/load_reporter.cc, line 30 at r5 (raw file):
We generally don't want these kind of conditional macros littered all over the code. Instead, we should have a separate file implementing this interface for each platform, and the entire file should be wrapped in a conditional. In other words, we should have a load_reporter_linux.cc where the entire file is wrapped in a @nicolasnoble can give you more pointers on how to set this up in the build system. src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 40 at r5 (raw file):
Do we have some guarantee that this will only be invoked from one thread at a time? If not, we'll need some synchronization. src/cpp/server/load_reporter/load_reporter_async_service_impl.cc, line 47 at r5 (raw file):
Same here. src/cpp/server/load_reporter/util.h, line 43 at r2 (raw file): Previously, AspirinSJL (Juanli Shen) wrote…
No. What I mean is a custom iterator class that wraps the original map but returns only the keys. You can think of this as a way of getting the kind of iterator you would get from I think we have an internal implementation of this kind of thing called In any case, I think that if you take my suggestion for how to simplify the code in load_data_store.cc, then this function is no longer needed, so this issue becomes moot. src/cpp/server/load_reporter/util.h, line 32 at r5 (raw file):
If we erase the last element in the value set, do we also want to remove the key from the map? src/cpp/server/load_reporter/util.h, line 47 at r5 (raw file):
These two functions are also probably not needed if you take my suggestions in load_data_store.cc. test/cpp/server/load_reporter/load_data_store_test.cc, line 36 at r5 (raw file):
The style guide prohibits a Instead, you'll need a Comments from Reviewable |
|
1 similar comment
|
|
1 similar comment
|
|
|
|
|
|
Review status: 3 of 11 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. src/cpp/server/load_reporter/load_data_store.cc, line 215 at r16 (raw file): Previously, markdroth (Mark D. Roth) wrote…
Done. Comments from Reviewable |
|
|
|
|
|
|
|
|
|
I will merge it when I get a LGTM from @summerxyt . |
|
LGTM |
50b33d7 to
ac0188e
Compare
|
|
2937bd4 to
a0aab7e
Compare
|
|
|
1 similar comment
|
|
The following description is for the whole service. But we've shrunk this PR to only contain the load data store files to make code review easier.
=============================
Adding a service to report load to balancers. Please check
src/proto/grpc/lb/v1/load_reporter.protofor details.Eventually this service will be a server plugin, but that will be addressed in a future PR.
For the service itself, we still need some API support from https://github.com/census-instrumentation/opencensus-cpp to finish the stats write/read.
The classes are organized as following:

The visibility of some class member variables can be stricter, but the friendship will be a little verbose?The classes can be declared in hierarchy, but they will be nested deeply.
This change is