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

Chance of reboot when uploading files #4

Open
denven opened this issue Jan 11, 2023 · 3 comments
Open

Chance of reboot when uploading files #4

denven opened this issue Jan 11, 2023 · 3 comments
Assignees
Labels
bug Something isn't working performance resolved

Comments

@denven
Copy link
Owner

denven commented Jan 11, 2023

when uploading large files (>4Mb), the camera has a chance of rebooting. It doesn't happen to each large mp4 file uploading, after uploading several large files, the camera reboots at some time.

@denven
Copy link
Owner Author

denven commented Jan 11, 2023

I got this screenshot from monitoring the camera performance and found it is when uploading files, the CPU is highly occupied by the curl request. This might be the issue that takes place.

image

And I also found that when uploading large files, it is very slow to complete the 2 chunks of one file's transmission.

Basically, the coding follows the API's best practice as the doc mentions, but the issue still exists.

https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_createuploadsession?view=odsp-graph-online

image

@denven denven self-assigned this Jan 11, 2023
@denven
Copy link
Owner Author

denven commented Jan 11, 2023

I remember during the tests of the initial stage of this repo code, it has no signs of reboot cases, there is one non-decent thing about using curl to upload files when using the option --data-binary, since it frequently throws the message which I cannot get rid of it from the terminal:

curl: option --data-binary: out of memory
curl: try 'curl --help' for more information

the file upload is fast and complete by this way, I just cannot stand this message, so I changed the input of curl by using @- from the command dd's output, as dd command provides options(bs and skip) to copy the file with specified size and position, it is very similar to split file into fragments by chunks.

Right now, I don't think it is a good way to use it, because it will increase memory usage. dd will read from the file, and output to another file, here the output is passed as curl's input. I think it triples memory usage since both dd and curl have to read the same amount of data, and dd outputs data as well. Meanwhile, it will increase the CPU usage rate, it is obvious from the top monitor screenshot. Thus, I should abandon this way.

It returns to the previous situation when I changed the code as previous, using curl to read from the file directly, files upload speed is faster, and the warning messages still continue to output.
image

Finally, I find why I cannot get rid of the standard error because I put the following in the code:

# -o /dev/null \
&> /dev/null

The commented-out line # -o /dev/null \ will make the command ignore the line (&> /dev/null ) after it. Because it converts the command to xxxxx # -o /dev/null &> /dev/null instead of xxxxx &> /dev/null, then the redirection will not work.

After removing the commented line, the curl output is clean ✌️

Update:: The root cause of reboot is here: dd can not work well with curl --data-binary on camera due to the limited memory resource, and the final solution is to call dd to split each video file into chunks, each time dd will cut one chunk into a tmp file, and then call curl --data-binary to read the chunk from the tmp file to upload until all file chunks are uploaded.

Resolved!

@denven
Copy link
Owner Author

denven commented Jan 11, 2023

After adding the headers option -H "Content-Type: application/octet-stream", the upload speed is even fast

@denven denven added the bug Something isn't working label Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance resolved
Projects
None yet
Development

No branches or pull requests

1 participant