journal: by default do not decompress dat objects larger than 64K
This introduces a new data threshold setting for sd_journal objects which controls the maximum size of objects to decompress. This is relieves the library from having to decompress full data objects even if a client program is only interested in the initial part of them. This speeds up "systemd-coredumpctl" drastically when invoked without parameters.
This commit is contained in:
+12
-2
@@ -91,7 +91,7 @@ static bool shall_print(const char *p, size_t l, OutputFlags flags) {
|
||||
if (flags & OUTPUT_SHOW_ALL)
|
||||
return true;
|
||||
|
||||
if (l > PRINT_THRESHOLD)
|
||||
if (l >= PRINT_THRESHOLD)
|
||||
return false;
|
||||
|
||||
if (!utf8_is_printable_n(p, l))
|
||||
@@ -119,6 +119,8 @@ static int output_short(
|
||||
assert(f);
|
||||
assert(j);
|
||||
|
||||
sd_journal_set_data_threshold(j, flags & OUTPUT_SHOW_ALL ? 0 : PRINT_THRESHOLD);
|
||||
|
||||
SD_JOURNAL_FOREACH_DATA(j, data, length) {
|
||||
|
||||
r = parse_field(data, length, "PRIORITY=", &priority, &priority_len);
|
||||
@@ -308,6 +310,8 @@ static int output_verbose(
|
||||
assert(f);
|
||||
assert(j);
|
||||
|
||||
sd_journal_set_data_threshold(j, 0);
|
||||
|
||||
r = sd_journal_get_realtime_usec(j, &realtime);
|
||||
if (r < 0) {
|
||||
log_error("Failed to get realtime timestamp: %s", strerror(-r));
|
||||
@@ -368,6 +372,8 @@ static int output_export(
|
||||
|
||||
assert(j);
|
||||
|
||||
sd_journal_set_data_threshold(j, 0);
|
||||
|
||||
r = sd_journal_get_realtime_usec(j, &realtime);
|
||||
if (r < 0) {
|
||||
log_error("Failed to get realtime timestamp: %s", strerror(-r));
|
||||
@@ -441,7 +447,7 @@ void json_escape(
|
||||
assert(f);
|
||||
assert(p);
|
||||
|
||||
if (!(flags & OUTPUT_SHOW_ALL) && l > JSON_THRESHOLD)
|
||||
if (!(flags & OUTPUT_SHOW_ALL) && l >= JSON_THRESHOLD)
|
||||
|
||||
fputs("null", f);
|
||||
|
||||
@@ -502,6 +508,8 @@ static int output_json(
|
||||
|
||||
assert(j);
|
||||
|
||||
sd_journal_set_data_threshold(j, flags & OUTPUT_SHOW_ALL ? 0 : JSON_THRESHOLD);
|
||||
|
||||
r = sd_journal_get_realtime_usec(j, &realtime);
|
||||
if (r < 0) {
|
||||
log_error("Failed to get realtime timestamp: %s", strerror(-r));
|
||||
@@ -714,6 +722,8 @@ static int output_cat(
|
||||
assert(j);
|
||||
assert(f);
|
||||
|
||||
sd_journal_set_data_threshold(j, 0);
|
||||
|
||||
r = sd_journal_get_data(j, "MESSAGE", &data, &l);
|
||||
if (r < 0) {
|
||||
/* An entry without MESSAGE=? */
|
||||
|
||||
Reference in New Issue
Block a user