Calling SevenZipArchiveEntry.OpenEntryStream skips the same parts again and again when reading entries in order #385

Open
opened 2026-01-29 22:11:04 +00:00 by claunia · 1 comment
Owner

Originally created by @poizan42 on GitHub (Dec 4, 2019).

SevenZipFilePart.GetCompressedStream skips all the previous files in the Folder. This involves decompressing them and discarding the decompressed data. So when reading the content of the Entries in order we keep decompressing the same data that we have already decompressed for every subsequent entry in the same CFolder! May I suggest that the folder stream be cached, e. g. by only re-creating if we need to read an entry earlier in the folder than the last one, so we don't end up like Shlemiel the Painter.

Shlemiel gets a job as a street painter, painting the dotted lines down the middle of the road. On the first day he takes a can of paint out to the road and finishes 300 yards of the road. “That’s pretty good!” says his boss, “you’re a fast worker!” and pays him a kopeck.

The next day Shlemiel only gets 150 yards done. “Well, that’s not nearly as good as yesterday, but you’re still a fast worker. 150 yards is respectable,” and pays him a kopeck.

The next day Shlemiel paints 30 yards of the road. “Only 30!” shouts his boss. “That’s unacceptable! On the first day you did ten times that much work! What’s going on?”

“I can’t help it,” says Shlemiel. “Every day I get farther and farther away from the paint can!”

Originally created by @poizan42 on GitHub (Dec 4, 2019). SevenZipFilePart.GetCompressedStream skips all the previous files in the Folder. This involves decompressing them and discarding the decompressed data. So when reading the content of the Entries in order we keep decompressing the same data that we have already decompressed for every subsequent entry in the same CFolder! May I suggest that the folder stream be cached, e. g. by only re-creating if we need to read an entry earlier in the folder than the last one, so we don't end up like Shlemiel the Painter. > Shlemiel gets a job as a street painter, painting the dotted lines down the middle of the road. On the first day he takes a can of paint out to the road and finishes 300 yards of the road. “That’s pretty good!” says his boss, “you’re a fast worker!” and pays him a kopeck. > > The next day Shlemiel only gets 150 yards done. “Well, that’s not nearly as good as yesterday, but you’re still a fast worker. 150 yards is respectable,” and pays him a kopeck. > > The next day Shlemiel paints 30 yards of the road. “Only 30!” shouts his boss. “That’s unacceptable! On the first day you did ten times that much work! What’s going on?” > > “I can’t help it,” says Shlemiel. “Every day I get farther and farther away from the paint can!”
claunia added the questionwontfix labels 2026-01-29 22:11:05 +00:00
Author
Owner

@adamhathcock commented on GitHub (Dec 4, 2019):

7Zip is an awful format that wants files to be compressed in a continuous stream. If you’re grabbing the compressed stream directly there’s not the library can do to make things nice for you.

Perhaps your solution will work for you. Sounds like you have it under control.

@adamhathcock commented on GitHub (Dec 4, 2019): 7Zip is an awful format that wants files to be compressed in a continuous stream. If you’re grabbing the compressed stream directly there’s not the library can do to make things nice for you. Perhaps your solution will work for you. Sounds like you have it under control.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#385