Samagra-Development / odk-collect-extension

ODK Collect is an Android app for filling out forms. ODK Collect Extensions is a layer on top of ODK Collect to make it easier to integrate inside existing Android apps.
https://docs.getodk.org/collect-intro
Apache License 2.0
5 stars 18 forks source link

Implemented Parallel Download of Forms using Multi-Threading and Locks #60

Open prabs3257 opened 1 year ago

prabs3257 commented 1 year ago

Closes #7

What has been done to verify that this works as intended?

Tested the code by artificially increasing the download time by adding delays, results show that the code works as intended. Verified that all the form files are being downloaded and saved properly.

Why is this the best possible solution? Were any other approaches considered?

Increases the performance of the app exponentially.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

This change does not affect the user

Do we need any specific form for testing your changes? If so, please attach one.

No

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No

Before submitting this PR, please make sure you have:

prabs3257 commented 1 year ago

@chinmoy12c These changes should make the media downloads also parallel and should properly shut down the executorservice and I have also released the locks in the catch blocks also. Also used locks in the downloadXForm function so that its thread safe. Is this correct ?

prabs3257 commented 1 year ago

@chinmoy12c @charanpreet-samagra I have set up my central project with 100 forms to simulate a demanding task. The proposed solution completes the download of all the forms in roughly 2 seconds (where download start time = 03:40:23.052 and end time = 03:40:25.000)

When the number of forms was increased in the project to 514. The proposed solution completes the download of all the forms in roughly 8 seconds (where download start time = 15:04:27.172 and end time = 15:04:35.285)

All these forms were simple forms with only one input field and no media attached. The bulk upload was done using ODK Central API and a self-written python script

This is the profiling when there are 514 forms to download

image
chinmoy12c commented 1 year ago

@chinmoy12c @charanpreet-samagra I have set up my central project with 100 forms to simulate a demanding task. The proposed solution completes the download of all the forms in roughly 2 seconds (where download start time = 03:40:23.052 and end time = 03:40:25.000)

When the number of forms was increased in the project to 514. The proposed solution completes the download of all the forms in roughly 8 seconds (where download start time = 15:04:27.172 and end time = 15:04:35.285)

All these forms were simple forms with only one input field and no media attached. The bulk upload was done using ODK Central API and a self-written python script

This is the profiling when there are 514 forms to download image

This is great @prabs3257. Could you make the final changes that I requested?