-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[bug]: fn/v2: test flake in TestPropForEachConcOutperformsMapWhenExpensive #9578
Comments
I am reviewing this issue and will share my findings shortly. |
The test Since the Map function operates sequentially, we expect ForEachConc to always complete first because it runs concurrently. However This becomes a problem, especially when the size of a slice is small. Although we have the following check for cases like that in the test: if len(s) < 2 {
// Intuitively we don't expect the extra overhead of
// ForEachConc to justify itself for list sizes of 1 or
// 0.
return true
} But from what I observed after running the test several times, the only failure instances occur when the size of the slice is 2. This means considering the overheads associated with (Another potential problem could arise when there aren't enough cores in the test environment. For instance, in a scenario where I can think of a few ways to resolve this issue. One option is to update the early return check to accommodate slices of size 2. if len(s) < 3 {...} We could also consider making the "expensive" operation more noticeable, for example, we can Perhaps a better solution would be to measure the execution time of Map and ForEachConc separately in a deterministic way, and then assert that ForEachConc is faster based on those results??. |
Yeah I think this approach is better. I also find it weird that we use a test to assert one method performs better than the other - we usually just benchmark them and print the results instead of assertion. In addition, I'm in favor of just removing |
Hey @yyforyongyu, what do you think finally about this issue then? Does this need to fixed?
|
Sounds good! I will investigate how benchmarking is done in other places and see how it will be applicable here as well. I would also like to hear others' opinions on the possibility of removing the |
So either the test is flaky, or the above property does not actually hold true.
Appeared in this build
The text was updated successfully, but these errors were encountered: