Skip to content
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

Migration/Clone events may be slow #16

Open
ChemiKyle opened this issue Feb 12, 2021 · 2 comments
Open

Migration/Clone events may be slow #16

ChemiKyle opened this issue Feb 12, 2021 · 2 comments

Comments

@ChemiKyle
Copy link
Contributor

ChemiKyle commented Feb 12, 2021

Using the XML from #14 I noticed that trying to migrate/clone the "Bai" data collection instrument was very slow. After clicking either option there was no indication that anything was happening. I was able to try to cancel the dialog box which resulted in the form's complete status not migrating! We should add a little spinner to the selection and maybe disable the buttons after clicking.

Hook the AJAX call here:

function ajaxMoveEvent(sourceEventId, targetEventId, formNames = null, deleteSourceData = false) {

If you need to add any parameters to the response, they can be included in the delete_response array returned by moveEvent:

return json_encode($delete_response);

UI updated in PR #17, I am leaving this issue open as a reminder to look for ways to optimize performance where possible.


Additionally I should probably optimize, I suspect I can save some speed here with by checking for edocs:

$log_message = $this->forceMigrateSourceFields($get_data, $project_id, $record_id, $source_event_id, $target_event_id, $log_message);

@ChemiKyle
Copy link
Contributor Author

ChemiKyle commented Feb 17, 2021

Unfortunately the slowness seems to be due to the core REDCap::saveData rather than my code.

I did some profiling using the same XML stated in the start of this issue, which has 1649 fields across 38 forms. I believe this function scales with a combination of these 2 factors (a quick and dirty calculation supports O(fields * ln(forms)).


Timing just after this step:

$new_data[$record_id][$target_event_id] = $old_data[$record_id][$source_event_id];

It takes about 25 seconds to complete this line:

$log_message = "Migrated form(s) " . $form_names . " from event " . $source_event_id . " to " . $target_event_id;

Which is due to redcap core.

The recursive array walk takes about half a millisecond:

// soft delete all data for each field
array_walk_recursive($old_data[$record_id][$source_event_id], function(&$value, $key) use ($record_pk) {

After which t takes an additional 28.5 seconds to complete this line:

$delete_response = REDCap::saveData($project_id, 'array', $old_data, 'overwrite');

@mbentz-uf
Copy link
Contributor

Migrated UI changes to issue #18.

@mbentz-uf mbentz-uf changed the title Migration/Clone events may be slow and should trigger UI changes Migration/Clone events may be slow Feb 26, 2021
@mbentz-uf mbentz-uf removed their assignment Apr 9, 2021
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

No branches or pull requests

2 participants