mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Add warnings for low thread and memory usage.
This commit is contained in:
parent
80f7d91044
commit
cdec0951d7
17
stream.c
17
stream.c
|
|
@ -937,9 +937,10 @@ bool close_streamout_threads(rzip_control *control)
|
||||||
void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_limit, char cbytes)
|
void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_limit, char cbytes)
|
||||||
{
|
{
|
||||||
struct stream_info *sinfo;
|
struct stream_info *sinfo;
|
||||||
|
unsigned int i, testbufs;
|
||||||
|
bool threadlimit = false;
|
||||||
i64 testsize, limit;
|
i64 testsize, limit;
|
||||||
uchar *testmalloc;
|
uchar *testmalloc;
|
||||||
unsigned int i, testbufs;
|
|
||||||
|
|
||||||
sinfo = calloc(sizeof(struct stream_info), 1);
|
sinfo = calloc(sizeof(struct stream_info), 1);
|
||||||
if (unlikely(!sinfo))
|
if (unlikely(!sinfo))
|
||||||
|
|
@ -975,20 +976,28 @@ void *open_stream_out(rzip_control *control, int f, unsigned int n, i64 chunk_li
|
||||||
/* If we don't have enough ram for the number of threads, decrease the
|
/* If we don't have enough ram for the number of threads, decrease the
|
||||||
* number of threads till we do, or only have one thread. */
|
* number of threads till we do, or only have one thread. */
|
||||||
while (limit < STREAM_BUFSIZE && limit < chunk_limit) {
|
while (limit < STREAM_BUFSIZE && limit < chunk_limit) {
|
||||||
if (control->threads > 1)
|
if (control->threads > 1) {
|
||||||
--control->threads;
|
--control->threads;
|
||||||
else
|
threadlimit = true;
|
||||||
|
} else
|
||||||
break;
|
break;
|
||||||
limit = (control->usable_ram - (control->overhead * control->threads)) / testbufs;
|
limit = (control->usable_ram - (control->overhead * control->threads)) / testbufs;
|
||||||
limit = MIN(limit, chunk_limit);
|
limit = MIN(limit, chunk_limit);
|
||||||
}
|
}
|
||||||
|
if (threadlimit) {
|
||||||
|
print_output("Minimising number of threads to %d to limit memory usage\n",
|
||||||
|
control->threads);
|
||||||
|
}
|
||||||
if (BITS32) {
|
if (BITS32) {
|
||||||
limit = MIN(limit, one_g);
|
limit = MIN(limit, one_g);
|
||||||
if (limit + (control->overhead * control->threads) > one_g)
|
if (limit + (control->overhead * control->threads) > one_g)
|
||||||
limit = one_g - (control->overhead * control->threads);
|
limit = one_g - (control->overhead * control->threads);
|
||||||
}
|
}
|
||||||
/* Use a nominal minimum size should we fail all previous shrinking */
|
/* Use a nominal minimum size should we fail all previous shrinking */
|
||||||
limit = MAX(limit, STREAM_BUFSIZE);
|
if (limit < STREAM_BUFSIZE) {
|
||||||
|
limit = MAX(limit, STREAM_BUFSIZE);
|
||||||
|
print_output("Warning, low memory for chosen compression settings\n");
|
||||||
|
}
|
||||||
limit = MIN(limit, chunk_limit);
|
limit = MIN(limit, chunk_limit);
|
||||||
retest_malloc:
|
retest_malloc:
|
||||||
testsize = limit + (control->overhead * control->threads);
|
testsize = limit + (control->overhead * control->threads);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue