Skip to content

Read release file sizes from the archive instead of extracting it - #76

Open
dionmcm wants to merge 1 commit into
IHTSDO:developfrom
aehrc:upstream/file-size-from-archive
Open

Read release file sizes from the archive instead of extracting it#76
dionmcm wants to merge 1 commit into
IHTSDO:developfrom
aehrc:upstream/file-size-from-archive

Conversation

@dionmcm

@dionmcm dionmcm commented Sep 1, 2026

Copy link
Copy Markdown

The snapshot and full file-size tests extracted four whole release directories — prospective and previous, snapshot and full — through ReleaseImporter, then called File.length() on the results. The uncompressed size of every entry is already in the ZIP central directory.

On a real 853 MB edition that extraction is about 100 seconds. It only runs when a previous release is supplied, so a first-time-release run never sees it, and a nightly comparing against last month's release always pays the cost.

Measured

Same release and request, 8 cores, before and after:

total the window containing the file-size tests
before 224 s 134 s
after 160 s 40 s

getSize() Checked against a full extraction of a release, 76 entries, zero mismatches, none returning the unknown -1.

Behaviour preserved

.txt entries only; paired on everything before the last underscore so the date suffix is dropped; first match wins; same messages and same KB rounding.

One difference - the error's filePath used to be the temporary extraction directory, which was deleted in a finally block before any reader could reach it. It is now the archive path.

Tests

Ten, over real zips built in the test. Two mutations were checked

  • removing the release-type filter fails onlyTheRequestedReleaseTypeIsReturned and anEmptyReleaseTypeYieldsNothingRatherThanFailing, so Snapshot and Full cannot silently begin comparing each other's files;
  • aSmallerProspectiveFileIsStillReported and anEqualOrLargerProspectiveFilePasses ensure that the rule still fires

The snapshot and full file-size tests extracted four whole release
directories - prospective and previous, snapshot and full - through
ReleaseImporter, and then called File.length() on the results. The
uncompressed size of every entry is in the ZIP central directory already.

On a real 853MB edition that extraction was around 100 seconds, and it
happens only when a previous release is supplied, so it is invisible to a
first-time-release run and unavoidable for a nightly that compares against
last month's release.

ZipEntry.getSize() is the uncompressed size and is exact: checked against a
full extraction of that release, 76 entries, zero mismatches and none
returning the unknown -1. Where an entry does return -1 - a zip written as a
stream, with sizes only in the trailing data descriptor - it is excluded
with a warning rather than compared against a guess, because a wrong size
here is a wrong finding about a release.

Threading the extraction was the other option and it is not worth having:
ZipFileUtils.extractFilesFromZipToOneFolder already parallelises, extracts
that edition in 4.5s at 1223 MB/s, and a hand-rolled largest-entry-first
pool only reached 4.2s. The cost was never the unzip that was needed, it was
the four that were not.

Behaviour preserved: .txt entries only, paired on everything before the last
underscore so the date suffix is dropped, first match wins, same messages
and same KB rounding. One visible difference - the error's filePath was the
temporary extraction directory, which was deleted in a finally block before
any reader could reach it, and is now the archive path.

Ten tests. Two mutations were checked rather than assumed: removing the
release-type filter fails two of them, so Snapshot and Full cannot silently
start comparing each other's files.
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

Successfully merging this pull request may close these issues.

1 participant