Take advantage of "zero-copy" feature of libarchive

Ask for help and post your question on how to use XnView MP.

Moderators: XnTriq, helmut, xnview

Denuvo
Posts: 12
Joined: Fri Jan 19, 2024 1:18 pm

Take advantage of "zero-copy" feature of libarchive

Post by Denuvo »

Hi! here's something we could do to optimize the performance when handling archives:

Seems currenly XnView MP just uses archive_read_data_into_fd to read and copy the file data from archive to a temploary file under local\temp folder, to generate thumbnail or to present on the screen.
We could use archive_read_data_block(not archive_read_data, which not suitable for dealing with large files) for obtaining file data instead, to aviod useing the temploary file and reduce the extra overhead of copy.
also this prevents the situation that a large video file in the archive could make xnview hang due to lack of space or slow copy speed.
User avatar
xnview
Author of XnView
Posts: 43098
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Take advantage of "zero-copy" feature of libarchive

Post by xnview »

ok, thanks. but the use archive_read_data_block will not change the use of temporary file
Pierre.
Denuvo
Posts: 12
Joined: Fri Jan 19, 2024 1:18 pm

Re: Take advantage of "zero-copy" feature of libarchive

Post by Denuvo »

xnview wrote: Thu Feb 01, 2024 8:22 am ok, thanks. but the use archive_read_data_block will not change the use of temporary file
Thanks for reply, unlike archive_read_data_into_fd, archive_read_data_block would just read the file data into the memory(even just a file mapping to the block of the original archive file if the archive is not using any algorithm for compression, like you choose store method for zip archive) instead of write the file data to the file on the disk. Is it necessary for XnView MP to create a temploary file for reading instead of just read the file from the memory?
User avatar
xnview
Author of XnView
Posts: 43098
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Take advantage of "zero-copy" feature of libarchive

Post by xnview »

Denuvo wrote: Fri Feb 02, 2024 5:21 pm Is it necessary for XnView MP to create a temploary file for reading instead of just read the file from the memory?
temporary file is needed
Pierre.