Skip to content
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 ArrayBufferView, ArrayOps.ArrayIterator and View.Patched #9388

Merged
merged 4 commits into from Oct 12, 2021

Conversation

NthPortal
Copy link
Contributor

@NthPortal NthPortal commented Dec 12, 2020

Ensure ArrayBufferView is consistent with its buffer.

Simplify ArrayBuffer#insertAll code.

Fix unreported bug in ArrayOps.ArrayIterator where
index in array can overflow to negative, and in such cases
the iterator reports hasNext incorrectly as true.

Improve code documentation and readability of
Iterator.patch implementation, which was bumped
into while investigating the bug.

Discovered while writing tests for bug in View.Patched
(see below).

Fix unreported bug in View.Patched where iterator
is incorrect due to the patch only being iterable once,
and already having been exhausted.

Discovered while attempting to optimise ArrayBuffer alongside
fixing ArrayBufferView (eventually scrapped).

Fixes scala/bug#12284

@NthPortal NthPortal added the library:collections PRs involving changes to the standard collection library label Dec 12, 2020
@scala-jenkins scala-jenkins added this to the 2.13.5 milestone Dec 12, 2020
@NthPortal NthPortal changed the title [bug#12284] Ensure ArrayBufferView is consistent with buffer [bug#12284][bug#12285] Fix ArrayBufferView and optimise ArrayBuffer#addAll Dec 12, 2020
@dwijnand dwijnand changed the title [bug#12284][bug#12285] Fix ArrayBufferView and optimise ArrayBuffer#addAll Fix ArrayBufferView and optimise ArrayBuffer#addAll Dec 17, 2020
@NthPortal

This comment has been minimized.

@SethTisue

This comment has been minimized.

@SethTisue

This comment has been minimized.

@SethTisue

This comment has been minimized.

@NthPortal

This comment has been minimized.

Copy link
Contributor

@julienrf julienrf left a comment

Choose a reason for hiding this comment

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

Thank you so much @NthPortal! (for your patience also…!)

src/library/scala/collection/View.scala Show resolved Hide resolved
src/library/scala/collection/mutable/ArrayBuffer.scala Outdated Show resolved Hide resolved
src/library/scala/collection/mutable/ArrayBuffer.scala Outdated Show resolved Hide resolved
project/MimaFilters.scala Outdated Show resolved Hide resolved
@NthPortal

This comment has been minimized.

@SethTisue SethTisue marked this pull request as draft January 26, 2021 17:03
@SethTisue

This comment has been minimized.

@lrytz
Copy link
Member

lrytz commented May 11, 2021

LGTM, again leaving to @SethTisue

@NthPortal NthPortal force-pushed the topic/fix-ArrayBufferView/PR branch 2 times, most recently from 6538cc8 to 01ce8db Compare May 13, 2021 07:33
@SethTisue SethTisue modified the milestones: 2.13.6, 2.13.7 May 13, 2021
@SethTisue

This comment has been minimized.

@SethTisue
Copy link
Member

@NthPortal hard to be totally sure, but afaict the ArrayBufferBenchmark I added over in #9258 should suffice for benchmarking this one as well

@NthPortal
Copy link
Contributor Author

NthPortal commented Aug 23, 2021

@SethTisue yes.

I'll have to review the changes, as it's been a really long time since I've looked at them, but I'm not even sure there's anything to benchmark

edit: we need to benchmark addAll. I don't think the current ArrayBufferBenchmark is sufficient, as we need to benchmark changes to the performance of addAll(IterableOnce), addAll(Iterable) and addAll(ArrayBuffer). I believe the benchmark currently only runs addAll(ArrayBuffer)

@SethTisue SethTisue requested a review from a team September 7, 2021 14:51
@SethTisue
Copy link
Member

2nd attempt to attract reviewer attention from @scala/collections crew and/or @julienrf

@julienrf
Copy link
Contributor

Hey, sorry I can’t review the PR soon.

Copy link
Contributor

@johnynek johnynek left a comment

Choose a reason for hiding this comment

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

maybe I suffer from anxiety, but given this is in the standard library, and given that we already have found bugs, I think we need more extensive tests. I've suggested two scalachecks to add.

test/junit/scala/collection/mutable/ArrayBufferTest.scala Outdated Show resolved Hide resolved
test/junit/scala/collection/ViewTest.scala Outdated Show resolved Hide resolved
@SethTisue
Copy link
Member

@NthPortal what's next here? are you interested in doing the ScalaCheck thing @johnynek suggested?

@dwijnand dwijnand removed the request for review from julienrf September 22, 2021 16:27
@NthPortal
Copy link
Contributor Author

@SethTisue i've been and continue to be sick, but i'll try to add the scalacheck stuff today or tomorrow. if i don't get to it, and @johnynek has perms, they can feel free to add a commit to this branch with it

@NthPortal
Copy link
Contributor Author

NthPortal commented Sep 24, 2021

oops I've bumped into ANOTHER unreported bug (by way of testing the fix for the first unreported bug too, not just separately as part of working on the main bug)

@NthPortal NthPortal changed the title Fix ArrayBufferView and View.Patched Fix ArrayBufferView, View.Patched and ArrayOps.ArrayIterator Sep 24, 2021
@NthPortal NthPortal changed the title Fix ArrayBufferView, View.Patched and ArrayOps.ArrayIterator Fix ArrayBufferView, ArrayOps.ArrayIterator and View.Patched Sep 24, 2021
@NthPortal NthPortal force-pushed the topic/fix-ArrayBufferView/PR branch 2 times, most recently from f7b43ca to 5a378ea Compare September 24, 2021 05:38
@NthPortal
Copy link
Contributor Author

this is done as far as I'm concerned

@NthPortal
Copy link
Contributor Author

@johnynek how do you feel about the tests now?

Ensure `ArrayBufferView` is consistent with its buffer.

Simplify `ArrayBuffer#insertAll` code.
Fix unreported bug in `ArrayOps.ArrayIterator` where
index in array can overflow to negative, and in such cases
the iterator reports `hasNext` incorrectly as `true`.

Improve code documentation and readability of
`Iterator.patch` implementation, which was bumped
into while investigating the bug.

Discovered while writing tests for bug in `View.Patched`
(see following commit).
Fix unreported bug in `View.Patched` where iterator
is incorrect due to the patch only being iterable once,
and already having been exhausted.

Discovered while attempting to optimise `ArrayBuffer` in an earlier
version of the previous commit.
@NthPortal NthPortal merged commit 5a4e273 into scala:2.13.x Oct 12, 2021
@NthPortal NthPortal deleted the topic/fix-ArrayBufferView/PR branch October 12, 2021 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library:collections PRs involving changes to the standard collection library
Projects
None yet
7 participants