-
Notifications
You must be signed in to change notification settings - Fork 77
Update table rows in C #1552
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
Update table rows in C #1552
Conversation
Looks good, and pretty rock solid as it uses the existing API. I feel we're really not sure this a bottleneck so happy to proceed with this version. |
OK, will tap away at this in my procrastination time. |
There should probably be a comment in the docs that one should not use this method to change every row in a table if one is concerned about speed. |
I changed the signature here to match tables.nodes[0] = tables.nodes[0].replace(flags=tskit.NODE_IS_SAMPLE) so we should make it efficient to do this. |
Codecov Report
@@ Coverage Diff @@
## main #1552 +/- ##
==========================================
- Coverage 93.75% 93.62% -0.13%
==========================================
Files 27 27
Lines 22647 22915 +268
Branches 1079 1076 -3
==========================================
+ Hits 21232 21454 +222
- Misses 1381 1427 +46
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
It would be good to get some eyes on this now @benjeffery before I embark on the copy-paste-athon. Notes:
Annoyingly, valgrind doesn't catch these undefined behaviours with memcpy on linux as it seems that under the hood somewhere memcpy is being replaced with memmove, and valgrind therefore doesn't see it. So, we'd have defined behaviour on some platforms, but not on others So, my take is to change to memmove anywhere we're taking pointers as input just to be on the safe side. |
This is probably compiler dependent. At least with GCC, memcpy can be inlined as an ordinary copying loop (e.g. using SSE instructions). |
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.
LGTM!
I'm happy with using memmove
throughout - I doubt the perf gain of memcpy
is significant.
This is ready to go now I think - there's a lot of code, so I think it's best to wait until @benjeffery gets back to merge. |
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.
LGTM, been through closely.
This is the simplest way I could think of doing #1545
There's a lot of different ways this could be made more efficient, but I think it's probably not worth trying unless we find it's a genuine bottleneck. I had a go at doing it more efficiently and (a) it'd be a lot more core, and (b) there's all sorts of tricky subtleties around memcpy'ing potentially overlapping buffers and changing pointer values because of potential reallocs. This is as dumb as rocks, but should be solid.
Any thoughts @benjeffery?