-
Notifications
You must be signed in to change notification settings - Fork 94
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
Immutable array based on RRB Vector #1286
base: main
Are you sure you want to change the base?
Conversation
Pull Request Test Coverage Report for Build 4819Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
After analyzing the git diff, here are three potential issues I've identified:
pub fn iter[A](self : T[A]) -> Iter[A] {
Iter::new(fn(yield_) {
let arr = self.to_array() // TODO: it first converts to an array, which is not efficient
// ...
})
} There's a comment indicating that the current implementation first converts the entire structure to an array before iteration, which is inefficient in terms of memory usage. This could be optimized by implementing a direct iterator over the tree structure.
let total_nodes = node_counts.fold(init=0, fn { acc, x => acc + x })
// round up to the nearest integer of S/branching_factor
let opt_len = (total_nodes + branching_factor - 1) / branching_factor There's no check for integer overflow when calculating
guard j < old_len // This shouldn't be triggered if the plan was correctly generated There's a comment suggesting that this guard should never fail if the plan is correct, but there's no validation of the plan before execution. If there's a bug in plan generation, this could lead to runtime errors. Consider adding validation of the redistribution plan before executing it. These issues primarily affect performance, memory efficiency, and robustness of the implementation. Would you like me to elaborate on any of these points? |
e46da1c
to
453569c
Compare
Originally I wanted to add In a nutshell, the main change of this PR is the introduction of the |
@jialunzhang-psu can you do a rebase? @Lampese are you interested in doing a review? |
OK, I will do it later. |
immut/array/array.mbt
Outdated
/// Physically copy the array. | ||
/// Since it is an immutable data structure, | ||
/// it is rarely the case that you would need this function. | ||
pub fn copy[A](self : T[A]) -> T[A] { |
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.
I'm not sure about the necessity of this API.
cc @peter-jerry-ye
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.
Hmm, I don't think it's necessary. Even it were, maybe it can just return itself?
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.
The API was already there when I touched it. I have no problem in removing it or making it private.
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.
IMO we need to remove it.
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.
I removed it.
This PR modifies the tree structure based on RRB Vector: A Practical General Purpose Immutable Sequence, ICFP'15. It will support operations including removal and concat.