Repository navigation
Fix lazy GenBank loading of multiple records - #1159
Conversation
josemduarte
left a comment
There was a problem hiding this comment.
Thank you. This looks good in principle. Just curious. Have you measured any change of performance with this updated implementation?
PositionTrackingReader.readLine() read one character at a time through BufferedReader.read(), which made eager GenBank reading slower. Keep a private character buffer and scan whole lines instead, with the same offset counting, mark/reset and CR, LF and CRLF handling.
|
Yes, I timed GenbankReaderHelper.readGenbankDNASequence at the base commit 8f151db and at this PR on JDK 17 (Temurin 17.0.21) on an Intel i9-13900 Linux server, with warm-up and 21 timed runs per case over 3 JVM launches. The first version made eager loading about 1.75x slower, for example from 246 ms to 429 ms for a generated 2000-record, 13 MB file, because the new readLine read one character at a time. I have pushed a revision that buffers that reader, and eager loading now measures at base speed (0.98x to 1.01x on all four test files) with the GenBank and FASTA reader and writer tests passing. Lazy loading now returns the right sequence for every record, where the old lazy path returned the first record's sequence for the later records in the multi-record files I measured, but it is slower than before on large files: from 86 ms to 198 ms at 500 records and from 382 ms to 2.0 s at 2000 records. That remaining cost is in SequenceFileProxyLoader, which skips from the start of the file to each record's offset and is outside the files this PR changes, and I can look at it in a follow-up if you want. |
With multiple records in a GenBank file,
readGenbankDNASequence(file, true)returns the first record's DNA for later accessions. Two records containingAB123456(AAAAAA) andAB123457(CCCCCC) both returnAAAAAA, even though the helper documents loading each sequence by accession.We now pass each record's character offset to the sequence creator, preserving it across parser lookahead and line endings. We added a regression test for eager versus lazy loading and consecutive
process(1)calls, and the reader and writer tests pass.Reproduced on base commit
8f151db1d376ed0311979bd6bc2131f0eea11c1a.— ChipLab