mirror of
https://github.com/vasi/pixz
synced 2024-11-03 09:40:24 +00:00
Find blocksize dynamically based on dict_size
This commit is contained in:
parent
5199636764
commit
4ca208ccd8
1
pixz.h
1
pixz.h
@ -14,7 +14,6 @@
|
|||||||
#define MEMLIMIT (64L * 1024 * 1024 * 1024) // crazy high
|
#define MEMLIMIT (64L * 1024 * 1024 * 1024) // crazy high
|
||||||
|
|
||||||
#define CHUNKSIZE 4096
|
#define CHUNKSIZE 4096
|
||||||
#define BLOCKSIZE (1024 * 1024)
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark TYPES
|
#pragma mark TYPES
|
||||||
|
11
write.c
11
write.c
@ -34,7 +34,7 @@ struct io_block_t {
|
|||||||
static pthread_t gEncodeThreads[ENCODE_THREADS];
|
static pthread_t gEncodeThreads[ENCODE_THREADS];
|
||||||
static pthread_t gReadThread;
|
static pthread_t gReadThread;
|
||||||
static queue_t *gEncodeQ, *gWriteQ;
|
static queue_t *gEncodeQ, *gWriteQ;
|
||||||
static size_t gBlockOutSize = 0;
|
static size_t gBlockInSize = 0, gBlockOutSize = 0;
|
||||||
|
|
||||||
static off_t gMultiHeaderStart = 0;
|
static off_t gMultiHeaderStart = 0;
|
||||||
static bool gMultiHeader = false;
|
static bool gMultiHeader = false;
|
||||||
@ -90,7 +90,8 @@ int main(int argc, char **argv) {
|
|||||||
.options = &lzma_opts };
|
.options = &lzma_opts };
|
||||||
gFilters[1] = (lzma_filter){ .id = LZMA_VLI_UNKNOWN, .options = NULL };
|
gFilters[1] = (lzma_filter){ .id = LZMA_VLI_UNKNOWN, .options = NULL };
|
||||||
|
|
||||||
gBlockOutSize = lzma_block_buffer_bound(BLOCKSIZE);
|
gBlockInSize = lzma_opts.dict_size * 1.0;
|
||||||
|
gBlockOutSize = lzma_block_buffer_bound(gBlockInSize);
|
||||||
|
|
||||||
// thread setup
|
// thread setup
|
||||||
gEncodeQ = queue_new();
|
gEncodeQ = queue_new();
|
||||||
@ -194,13 +195,13 @@ static void *read_thread(void *data) {
|
|||||||
static ssize_t tar_read(struct archive *ar, void *ref, const void **bufp) {
|
static ssize_t tar_read(struct archive *ar, void *ref, const void **bufp) {
|
||||||
if (!gReadBlock) {
|
if (!gReadBlock) {
|
||||||
gReadBlock = malloc(sizeof(io_block_t));
|
gReadBlock = malloc(sizeof(io_block_t));
|
||||||
gReadBlock->input = malloc(BLOCKSIZE);
|
gReadBlock->input = malloc(gBlockInSize);
|
||||||
gReadBlock->output = malloc(gBlockOutSize);
|
gReadBlock->output = malloc(gBlockOutSize);
|
||||||
gReadBlock->insize = 0;
|
gReadBlock->insize = 0;
|
||||||
gReadBlock->seq = gBlockNum++;
|
gReadBlock->seq = gBlockNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t space = BLOCKSIZE - gReadBlock->insize;
|
size_t space = gBlockInSize - gReadBlock->insize;
|
||||||
if (space > CHUNKSIZE)
|
if (space > CHUNKSIZE)
|
||||||
space = CHUNKSIZE;
|
space = CHUNKSIZE;
|
||||||
uint8_t *buf = gReadBlock->input + gReadBlock->insize;
|
uint8_t *buf = gReadBlock->input + gReadBlock->insize;
|
||||||
@ -211,7 +212,7 @@ static ssize_t tar_read(struct archive *ar, void *ref, const void **bufp) {
|
|||||||
gTotalRead += rd;
|
gTotalRead += rd;
|
||||||
*bufp = buf;
|
*bufp = buf;
|
||||||
|
|
||||||
if (gReadBlock->insize == BLOCKSIZE) {
|
if (gReadBlock->insize == gBlockInSize) {
|
||||||
queue_push(gEncodeQ, MSG_BLOCK, gReadBlock);
|
queue_push(gEncodeQ, MSG_BLOCK, gReadBlock);
|
||||||
gReadBlock = NULL;
|
gReadBlock = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user