haiku/headers/private/package/hpkg/PackageFileHeapReader.h
Augustin Cavalier f44cb411cc Package Kit & packagefs: Allocate scratch buffers for decompression further up.
Zstd wants a ~90 KB scratch buffer to decompress our 64 KB chunks.
Rather than let it allocate that itself every time, pass in a 2*64KB
"scratch" buffer and statically allocate the working memory from it.
Pass it down using iovecs, and pass down the other buffers in the same
way, to reduce parameters.

Further, rework the object_cache used for heap decompression buffers
to contain objects sized as 4x64KB, so we only need to do one allocation
and deallocation for the compression/decompression and scratch buffers.
Set the minimum reserve to 1 so that the low-memory manager doesn't
reclaim this, as we'll need it when reading back data.

Improves packagefs I/O performance (and thus boot speeds at least a bit,
it appears.)

Change-Id: Id51f6f598b33b9d757a283184c533bb97049529f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8717
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
2024-12-30 19:04:10 +00:00

61 lines
1.3 KiB
C++

/*
* Copyright 2013, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_READER_H_
#define _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_READER_H_
#include <Array.h>
#include <package/hpkg/PackageFileHeapAccessorBase.h>
namespace BPackageKit {
namespace BHPKG {
class BDataReader;
class BErrorOutput;
namespace BPrivate {
class PackageFileHeapReader : public PackageFileHeapAccessorBase {
public:
PackageFileHeapReader(BErrorOutput* errorOutput,
BPositionIO* file, off_t heapOffset,
off_t compressedHeapSize,
uint64 uncompressedHeapSize,
DecompressionAlgorithmOwner*
decompressionAlgorithm);
~PackageFileHeapReader();
status_t Init();
PackageFileHeapReader* Clone() const;
const OffsetArray& Offsets() const
{ return fOffsets; }
protected:
virtual status_t ReadAndDecompressChunk(size_t chunkIndex,
void* compressedDataBuffer,
void* uncompressedDataBuffer,
iovec* scratchBuffer = NULL);
private:
OffsetArray fOffsets;
};
} // namespace BPrivate
} // namespace BHPKG
} // namespace BPackageKit
#endif // _PACKAGE__HPKG__PRIVATE__PACKAGE_FILE_HEAP_READER_H_