diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-02-17 14:15:00 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-02-17 14:15:00 +0100 |
commit | d3438f29f44afccd6c5439a111a0bdf42126f7f9 (patch) | |
tree | e8c85895ccc272cdfe75d0b220ff51de92599a01 /container-core | |
parent | 37fd0e320d0f78c0442fa73fdaddaec33c916d28 (diff) |
Flush based on characters instead of lines to keep a small predictable memory footprint.
1M should be enough for efficiency. An improvement would be to count sent and acked bytes separately.
Diffstat (limited to 'container-core')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/LogReader.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/LogReader.java b/container-core/src/main/java/com/yahoo/container/handler/LogReader.java index ea2f431f5a6..a7fcb8a9f71 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/LogReader.java +++ b/container-core/src/main/java/com/yahoo/container/handler/LogReader.java @@ -72,12 +72,16 @@ class LogReader { Iterator<LineWithTimestamp> lines = Iterators.mergeSorted(logLineIterators, Comparator.comparingDouble(LineWithTimestamp::timestamp)); - long linesWritten = 0; + long charsWritten = 0; while (lines.hasNext()) { - writer.write(lines.next().line()); + String line = lines.next().line(); + writer.write(line); writer.newLine(); - if ((++linesWritten & ((1 << 16) - 1)) == 0) + charsWritten += line.length(); + if (charsWritten > 0x100000) { writer.flush(); + charsWritten = 0; + } } } catch (IOException e) { @@ -188,9 +192,11 @@ class LogReader { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - if ( logFilePattern.matcher(file.getFileName().toString()).matches() + if (logFilePattern.matcher(file.getFileName().toString()).matches() && ! attrs.lastModifiedTime().toInstant().isBefore(from)) + { paths.add(file); + } return FileVisitResult.CONTINUE; } |