[WIP] Rework of immutable.Queue to avoid copying data into the "in" list#8602
Closed
joshlemer wants to merge 4 commits intoscala:2.13.xfrom
Closed
[WIP] Rework of immutable.Queue to avoid copying data into the "in" list#8602joshlemer wants to merge 4 commits intoscala:2.13.xfrom
joshlemer wants to merge 4 commits intoscala:2.13.xfrom
Conversation
Member
|
@joshlemer interested in returning to this? |
Member
|
Closing for inactivity. @joshlemer feel free to open a ticket to save the idea + link to the WIP here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a reworking of the structure of Queue's
in: List[A]to be now aList[A | Many[A]], which allows forenqueueAlloperations to be performed in O(1) by simply settingWhen a rotation happens (when a dequeueing occurs which causes us to rotate the
inlist to theoutlist, at that point, theinlist is flattened to construct the newoutlist.The end result is that instead of copying the data twice (copying once into
inand again to rotate intoout), we only perform one copying of the data, at rotation-time. We avoid the equeueAll-time copying by appending prepending the collection itself as the first element ofin.An other more elaborated description was written here: #8565 (comment)
This is a very early version of this PR and it is definitely not ready for merging.
Also, this one is on pause until at least #8601 is through, since this code somewhat depends on that code to realize performance improvements, so benchmarks compared to the 2.13.x branch are underwhelming or even negative.
TODO
Run benchmarks to ensure that the expected speedups are indeed worth the complexity, and other operations on queues are not slowed down (by much)
Write more unit/prop tests for queues
Implement faster
queue.apply(Int)implementationExtract iterator class from queue
Make any necessary changes to Queue scaladocs and if applicable, scala-lang.org