Repository navigation
Gather a small group's rows on one thread - #464
Merged
Merged
Conversation
# Conflicts: # r-package/dtatools/NEWS.md
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Summary
C_dtatools_gather_numeric_columns()gathers rows of several Stata numeric columns at once. Its Rust kernel started a scoped worker thread for each column, up to the processor count, on every call with more than one column. A grouped verb gathers each group's few rows of every column in its own call, sonest_by(),group_nest()andgroup_split()paid for starting those threads once for each group. Gathering two rows of eight columns took about 46 µs, where one thread takes 1.5 µs.This PR starts one worker for each 16,384 values a gather copies, up to the column count and the processor count, and gathers on the calling thread when that comes to one worker. A gather of one column or few values returns before it asks the system for the processor count, which a grouped read of one column would otherwise ask once for each group.
Behavior
Results are unchanged. Each worker writes the same bytes to its own columns, so the number of workers changes only the time. No ADR records the threads, so none changes.
Timing
Best of three runs in fresh R sessions, in seconds, with the builds interleaved, over the 42,739 women in the first 100,000 rows of the India 2021 DHS births file. Before is main.
nest_by(b, caseid)group_split(group_by(b, caseid))group_nest(b, caseid).split_dta_column()of a byte column into 50,000 chunks of three rowsOne call that gathers sorted random rows of eight columns of the births file took these times, in microseconds:
Tests