-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Read all EventGroups from simulators rather than stopping at first page #1927
fix: Read all EventGroups from simulators rather than stopping at first page #1927
Conversation
Depends on #1923 |
ac2d7cf
to
f23d4e4
Compare
f23d4e4
to
c21917a
Compare
120f1a2
to
ddfb970
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 6 files at r1, 2 of 14 files at r2, all commit messages.
Reviewable status: 4 of 20 files reviewed, 1 unresolved discussion (waiting on @SanjayVas)
src/main/kotlin/org/wfanet/measurement/common/api/grpc/ListResources.kt
line 67 at r2 (raw file):
val resourceList: ResourceList<T> = list(nextPageToken, remaining) require(resourceList.size <= remaining) {
should this really be required here and throw an error? this is a problem with the list that is passed in..... meaning an API that returned too many items. I'd prefer it took only that many elements if there are too many.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 of 20 files reviewed, 1 unresolved discussion (waiting on @stevenwarejones)
src/main/kotlin/org/wfanet/measurement/common/api/grpc/ListResources.kt
line 67 at r2 (raw file):
I'd prefer it took only that many elements if there are too many.
That wouldn't work, as the returned next page token wouldn't have the right value to get subsequent items.
c21917a
to
41e3364
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 4 of 20 files reviewed, 1 unresolved discussion (waiting on @stevenwarejones)
src/main/kotlin/org/wfanet/measurement/common/api/grpc/ListResources.kt
line 67 at r2 (raw file):
Previously, SanjayVas (Sanjay Vasandani) wrote…
I'd prefer it took only that many elements if there are too many.
That wouldn't work, as the returned next page token wouldn't have the right value to get subsequent items.
Also GitHub got a bit confused and included changes from the base PR. I assume this comment was meant for #1923
41e3364
to
8c94407
Compare
ddfb970
to
ebeeba9
Compare
8c94407
to
61fb437
Compare
f761ae0
to
668fa73
Compare
61fb437
to
81f7ed9
Compare
668fa73
to
929c89a
Compare
81f7ed9
to
673ba6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 20 of 20 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @SanjayVas)
src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt
line 369 at r3 (raw file):
} .flattenConcat() .firstOrNull { it.eventGroupReferenceId == eventGroupReferenceId }
I'd prefer you prefilter instead of unncessarily fetching all event groups.... something like
eturn eventGroupsStub
.listResources(
limit = 1
) { pageToken ->
val response =
try {
listEventGroups(
listEventGroupsRequest {
parent = edpData.name
filter =
ListEventGroupsRequestKt.filter {
measurementConsumers += measurementConsumerName
}
this.pageToken = pageToken
}
)
} catch (e: StatusException) {
throw Exception("Error listing EventGroups", e)
}
ResourceList(
response.eventGroupsList.filter { it.eventGroupReferenceId == eventGroupReferenceId },
response.nextPageToken
)
}
.flattenConcat()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @stevenwarejones)
src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt
line 369 at r3 (raw file):
Previously, stevenwarejones (Steven Ware Jones) wrote…
I'd prefer you prefilter instead of unncessarily fetching all event groups.... something like
eturn eventGroupsStub .listResources( limit = 1 ) { pageToken -> val response = try { listEventGroups( listEventGroupsRequest { parent = edpData.name filter = ListEventGroupsRequestKt.filter { measurementConsumers += measurementConsumerName } this.pageToken = pageToken } ) } catch (e: StatusException) { throw Exception("Error listing EventGroups", e) } ResourceList( response.eventGroupsList.filter { it.eventGroupReferenceId == eventGroupReferenceId }, response.nextPageToken ) } .flattenConcat()
That would be less efficient as it means making a call for one EventGroup at a time rather than batching by the default page size. This will still stop making calls once we get a response that contains the event group.
929c89a
to
6d2017a
Compare
673ba6f
to
7f251b2
Compare
6d2017a
to
e6320aa
Compare
7f251b2
to
4bf8612
Compare
e6320aa
to
43fef9d
Compare
4bf8612
to
e026654
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @stevenwarejones)
src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt
line 369 at r3 (raw file):
Previously, SanjayVas (Sanjay Vasandani) wrote…
That would be less efficient as it means making a call for one EventGroup at a time rather than batching by the default page size. This will still stop making calls once we get a response that contains the event group.
To clarify, what I mean is that the implementation in this PR will already stop making requests once it gets a response that has an EventGroup that has the specified reference ID. This is because Flow.flattenConcat
is an intermediate Flow operator analogous to Sequence.flatten
.
Your suggestion does not add any benefit and furthermore does not meet the constraint of never returning more items than limit
since EventGroup reference IDs are not yet guaranteed to be unique (see #1913). In order to meet that constraint, it would have to pass the remaining
value as the pageSize
in the request resulting in the non-batching behavior I mentioned.
e026654
to
7b4e922
Compare
43fef9d
to
1391cab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @SanjayVas)
src/main/kotlin/org/wfanet/measurement/loadtest/dataprovider/EdpSimulator.kt
line 369 at r3 (raw file):
Previously, SanjayVas (Sanjay Vasandani) wrote…
To clarify, what I mean is that the implementation in this PR will already stop making requests once it gets a response that has an EventGroup that has the specified reference ID. This is because
Flow.flattenConcat
is an intermediate Flow operator analogous toSequence.flatten
.Your suggestion does not add any benefit and furthermore does not meet the constraint of never returning more items than
limit
since EventGroup reference IDs are not yet guaranteed to be unique (see #1913). In order to meet that constraint, it would have to pass theremaining
value as thepageSize
in the request resulting in the non-batching behavior I mentioned.
I was not aware that Flow.flattenConcat would end up causing the requests to stop once an event group is found.
However, I think you're misunderstanding what what I suggested... I'm suggesting that the listPredicate itself filter out non-matching resource names. That means that it will always return either 1 or 0 items. If it finds no matches, it returns 0 items. Otherwise, it returns 1. Once once is returned, there is no need to continue. I think this is a little more straightforward. The reader may read your code and make the same assumption I did.
…ion (#1923) This also fixes an issue where EventGroupsServiceTest was waiting for a real 30s deadline to pass. Also fixes the simulator issue of PR #1927: The MC and EDP simulators were only reading the first page of results from ListEventGroups. This means that in environments with more EventGroups, not all test EventGroups would be read. This is exacerbated by #1916, as the default page size is now smaller.
The MC and EDP simulators were only reading the first page of results from ListEventGroups. This means that in environments with more EventGroups, not all test EventGroups would be read. This is exacerbated by #1916, as the default page size is now smaller.