Skip to content

Import of problem zip slow with many submission files #2019

Open
@eldering

Description

@eldering

Importing example_problems/hello as a zip takes about 10 seconds, and almost all of that time seems spent importing the submissions.

I think the problem is the double for loop over the files in the zip at

for ($j = 0; $j < $zip->numFiles; $j++) {
$path = $zip->getNameIndex($j);
if (!Utils::startsWith($path, 'submissions/')) {
// Skipping non-submission files silently.
continue;
}
$pathComponents = explode('/', $path);
if (!((count($pathComponents) == 3 && !empty($pathComponents[2])) ||
(count($pathComponents) == 4 && empty($pathComponents[3])))) {
// Skipping files and directories at the wrong level.
// Note that multi-file submissions sit in a subdirectory.
continue;
}
if (count($pathComponents) == 3) {
// Single file submission
$files = [$pathComponents[2]];
$indices = [$j];
} else {
// Multi file submission
$files = [];
$indices = [];
$length = mb_strrpos($path, '/') + 1;
$prefix = mb_substr($path, 0, $length);
for ($k = 0; $k < $zip->numFiles; $k++) {
, which may become slow when there's in the case of hello 223 files/directories in the zip file.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions