refactor: For MutableCSR, Let degree/cap list directly open in container and avoid copy in dump#267
Merged
Conversation
Contributor
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #265 by refactoring MutableCsr to open and dump the degree (.deg) and capacity (.cap) lists directly via OpenContainer, reducing redundant O(V) element-wise copies during open/dump and aligning the approach with how the neighbor list is handled.
Changes:
- Refactor
MutableCsr::open_internal()anddump()to useOpenContainer()/IDataContainer::Dump()directly for.degand.cap. - Replace the previous
std::atomic<int>-backed degree buffer usage with anintbuffer and atomic builtins in selected write paths. - Minor formatting tidy in a test and ignore
.aone_copilot/in.gitignore.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/storages/csr/mutable_csr.cc |
Open/dump degree & capacity lists via containers; adjust degree access patterns across CSR ops. |
include/neug/storages/csr/mutable_csr.h |
Update member containers and degree access in put_edge()/views to use the new degree/cap containers. |
tests/execution/test_value.cc |
Formatting-only change to an EXPECT_DEATH call. |
.gitignore |
Add .aone_copilot/ ignore entry. |
Comments suppressed due to low confidence (2)
src/storages/csr/mutable_csr.cc:448
delete_edgebounds-checksoffsetagainstsz_arr[src]using a plain read from the degree array. Since degrees are incremented with atomic RMWs input_edge/batch_put_edges, this non-atomic read can race with concurrent inserts/deletes and is undefined behavior in C++. Use an atomic load (e.g.,std::atomic_ref<int>(sz_arr[src]).load(std::memory_order_relaxed)or__atomic_load_n) or ensure higher-level synchronization guarantees no concurrent degree modifications when calling this API.
THROW_INVALID_ARGUMENT_EXCEPTION("src out of bound or offset out of bound");
}
nbr_t* nbrs = reinterpret_cast<nbr_t**>(adj_list_buffer_->GetData())[src];
if (nbrs == nullptr) {
src/storages/csr/mutable_csr.cc:558
- In
batch_put_edges, degrees are read/written via plainintaccesses in earlier loops, but later updated with__atomic_fetch_add(&sz_arr[src], ...). Mixing atomic and non-atomic accesses to the same locations is undefined behavior and can lead to inconsistent degrees under concurrent readers/writers. Consider switching all degree accesses in this method tostd::atomic_ref<int>(or__atomic_*builtins) for consistency, or clearly document/enforce thatbatch_put_edgesruns single-threaded with no concurrent readers.
nbr.data = data;
nbr.timestamp.store(ts);
added_edge_num++;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2ed3596 to
14f8432
Compare
format minor fix no need to use atomic for degree remove need_cap_list
14f8432 to
c964e58
Compare
liulx20
approved these changes
Apr 23, 2026
Merged
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.
Fix #265