Skip to content

Simplify deepcopy for potential performance improvements - #5277

Merged
ajpotts merged 1 commit into
Bears-R-Us:mainfrom
jabraham17:simplify-deepcopy
Jan 12, 2026
Merged

ajpotts merged 1 commit into
Bears-R-Us:mainfrom
jabraham17:simplify-deepcopy

Conversation

@jabraham17

Copy link
Copy Markdown
Contributor

Simplifies the deepcopy implementation to just use array assignment.

The previous implementation in the 1-node cases would result in fine-grained array accesses and in the multi-node case would do manual slicing/bulk copies. However, the builtin array assignment operator is already optimized for this. In the single node case for a trivial array it will result in a single memcpy and in the multi-node case it will result in a single memcpy per locale (assuming the same distribution).

Signed-off-by: Jade Abraham <[email protected]>
@jabraham17
jabraham17 requested a review from drculhane January 9, 2026 16:11
@e-kayrakli

Copy link
Copy Markdown
Contributor

single node case for a trivial array it will result in a single memcpy

To correct and amplify your point, we do better than that. If the data is large enough, using multiple cores to memcpy chunks of data results in much higher memory bandwidth utilization across different systems. By default, local array to array assignments benefit from that. I believe a typical C program that would copy "arrays" using a single memcpy would underperform compared to a Chapel application that copies arrays using array assignment as you are doing here. The default threshold for this to kick in is 2MB of data, and can be controlled via -sparallelAssignThreshold at compile time.

The PR that added the optimization has some data if you are curious: chapel-lang/chapel#16418 (comment)

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@4b458d1). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #5277   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?        44           
  Lines           ?      1208           
  Branches        ?         0           
========================================
  Hits            ?      1208           
  Misses          ?         0           
  Partials        ?         0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jabraham17
jabraham17 requested a review from ajpotts January 12, 2026 16:24

@drculhane drculhane left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Simplicity is a beautiful thing.

@ajpotts
ajpotts added this pull request to the merge queue Jan 12, 2026
Merged via the queue into Bears-R-Us:main with commit 6070589 Jan 12, 2026
@jabraham17
jabraham17 deleted the simplify-deepcopy branch January 12, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants