show file size of archived courses when unarchiving - #3047
Conversation
|
This now has a few styling changes too, in separate commits. |
drgrice1
left a comment
There was a problem hiding this comment.
I think it would be better to just update the listArchivedCourses method (instead of adding the statArchivedCourses method), and use the same format for showing archive files in the UI in the two places that is done (and the only two places where the listArchivedCourses method is used before this pull request). The two places are when unarchiving courses and on the main course admin page that lists courses and archived courses.
|
Part of the reason that I suggest just updating the If the two methods were combined much of that inefficiency and code clutter could be cleaned up. You just have to update lines 68-70 of Actually, I have put in a pull request to this branch that does the things I have mentioned. |
The `listArchiveCourses` also stats the archive files found and returns the files as a hash whose keys are the course ids and the values are references to hashes containing the `filename` (the basename of the file including the `.tar.gz` extension) and file `size` Both of the places that use the `listArchiveCourses` method are updated to use this return value.
Combine the `listArchiveCourses` and `statArchiveCourses` methods.
drgrice1
left a comment
There was a problem hiding this comment.
There are a few changes to the latest additions needed.
15c4542 to
298e24b
Compare
|
Thanks for those notes. I applied them and squashed them in with the commit that moved to using the tarball's top folder. |
|
This can be merged now that #4043 has been. |
|
Now that this is in production, I notice that on my server (I have 60 archives and older hardware) it takes 30 seconds of server at 100cpu time to list the archives. In my case the .tar.gz name and the archive name are the same, so there is a lot of unneeded computation to look in each .tar.gz. Part of the issue is since the archives are listed on the index page of the admin course, this happens a lot (not just when visiting the unarchive page). I don't think it is worth looking in each and every archive when listing them. I would just assume the file name is correct, maybe have a tool that checks archives and lets the user know if the filename doesn't match the directory in the archive and let them rename them. |
|
I did not study @drdrew42's code that identifies the top level folder name in the archive. The regular Looking over |
|
@Alex-Jordan I can test things out if you like (haven't looked at the code so you'll have to send patches). I still think it is unneeded overhead in lots of cases on the main "Course List" page. Maybe only do that on the "unarchive courses" page and could add some warning if the file name differs from the actual course, while on the may "Course List" page just trust the filename. |
|
I attempted to use I also removed all calls to |
|
I cheated and used Claude. Does this patch speed things up or relieve your CPU? The idea here is what I described before. Claude's testing benchmarked a 600x speedup. I am cooking dinner and haven't actually tested that this functions. Like, that it still shows the actual name of the top level folder. |
|
I don't think this is actually working. It is showing the file name of an archive that has a different name for its top level folder. I will investigate later tonight, and hopefully find a quick patch. Or abandon it and just list the file names in the first place on the Course Listings page. That's what this PR originally set out to do, but it coincided with the time that @drdrew42 was doing the other thing over in Unarchive, so we took the same approach here. But yes, if it slows the Course Listings page down too much, that won't be acceptable. |
|
Er wait, I think it might be working. I was looking at the wrong place. If you are testing, let me know what you find. |
|
Hmm, I packed my dev server with a bunch of archive courses. And with or without this change, the course listings page is taking about 2.-2.8 seconds to load. My 2.20 production server, with far more archives, takes only 1.1 second on average. I'd like to hear what @drgrice1 thinks. But it seems like this may need to either not list the archived courses, or revert to just printing the files. |
|
@Alex-Jordan The provided patch didn't speed it up, for me the creating of the archive object is what seems to take time. My server is quite old (15-20 years) so no ssd, etc. Might just be a hardware limitation, but it works just fine, unsure why this is taking longer for 60 archived files compared to what you have tested. |
|
As I told @somiaj in Slack, I noticed this show down on my test server immediately after this pull request went in. I also tested commenting out all but the line that opens the tar archive file (so skipping all processing after that), and then using the file name for the hash key, and the slow down still occurs. So the mere act of constructing the One solution would be to do what @somiaj suggested in Slack, and cache the results of parsing the archive files. The first time the page loads it would still take a while, but after that it would load fast. I was planning to implement this. Basically, save the archive filename, last modified time, and identified course name in a JSON file in the root of the admin course. Then read that, check modified times and update as needed. |
|
I am opposed to using a system utility, and actually doubt that it would be faster. |
|
I did a test with calling To me caching the data is probably the best as archives don't change that often. Maybe the cache should also be updated when an archive is created and not just when listing them. The only other option I can think of is trust the file name for the archive list, and have some utility to check archives on the "unarchive course" page to let users know if the file name differs from the course ID. Though this would probably have to be manually run or done via a cache system to make that page not load so slowly with large archives. Since it sounds like @drgrice1 is working on a caching method, that sounds good to me. |
When at the Unarchive courses page, the list of courses now leaves off the ".tar.gz" and includes the size of the file to be unarchived. This will help me identify inefficiencies with how RS users are handling their courses. If I am about to unarchive a particularly large course, I will then go into it and see what can be trimmed. Usually, the faculty have put course archive files in their course. Or they are using images inefficiently. Or they copied entire folder trees for backup before editing local pg files.
I did this in a way to make it extensible. Perhaps there would be interest in also showing the date the archive file was last modified. Perhaps this is of tangential interest to @drdrew42 with #3043 in that the displayed course name could be the actual internal course name, not the file name with
.tar.gztruncated off.