Repository: envoyproxy/envoy
File: source/common/access_log/access_log_manager_impl.h (C/C++)

Code before:
  Thread::MutexBasicLockable
      write_lock_; // The lock is used when filling the flush buffer. It allows
                   // multiple threads to write to the same file at relatively
                   // high performance. It is always local to the process.
  Thread::ThreadPtr flush_thread_;
  Thread::CondVar flush_event_;
  bool flush_thread_exit_ ABSL_GUARDED_BY(write_lock_){false};
  bool reopen_file_ ABSL_GUARDED_BY(write_lock_){false};
  Buffer::OwnedImpl
      flush_buffer_ ABSL_GUARDED_BY(write_lock_); // This buffer is used by multiple threads. It
                                                  // gets filled and then flushed either when max
                                                  // size is reached or when a timer fires.
  // TODO(jmarantz): this should be ABSL_GUARDED_BY(flush_lock_) but the analysis cannot poke
  // through the std::make_unique assignment. I do not believe it's possible to annotate this
  // properly now due to limitations in the clang thread annotation analysis.
  Buffer::OwnedImpl about_to_write_buffer_; // This buffer is used only by the flush thread. Data
                                            // is moved from flush_buffer_ under lock, and then
                                            // the lock is released so that flush_buffer_ can
                                            // continue to fill. This buffer is then used for the
                                            // final write to disk.
  Event::TimerPtr flush_timer_;
  Thread::ThreadFactory& thread_factory_;
  const std::chrono::milliseconds flush_interval_msec_; // Time interval buffer gets flushed no
                                                        // matter if it reached the MIN_FLUSH_SIZE
                                                        // or not.
  const uint64_t min_flush_size_; // Minimum size before the flush thread will be told to flush.
  AccessLogFileStats& stats_;
};

} // namespace AccessLog
} // namespace Envoy


Review comment (suggestion):
```suggestion
  const uint64_t min_flush_size_{64 * 1024}; // Minimum size before the flush thread will be told to flush.
```

Code after:
  Thread::MutexBasicLockable
      write_lock_; // The lock is used when filling the flush buffer. It allows
                   // multiple threads to write to the same file at relatively
                   // high performance. It is always local to the process.
  Thread::ThreadPtr flush_thread_;
  Thread::CondVar flush_event_;
  bool flush_thread_exit_ ABSL_GUARDED_BY(write_lock_){false};
  bool reopen_file_ ABSL_GUARDED_BY(write_lock_){false};
  Buffer::OwnedImpl
      flush_buffer_ ABSL_GUARDED_BY(write_lock_); // This buffer is used by multiple threads. It
                                                  // gets filled and then flushed either when max
                                                  // size is reached or when a timer fires.
  // TODO(jmarantz): this should be ABSL_GUARDED_BY(flush_lock_) but the analysis cannot poke
  // through the std::make_unique assignment. I do not believe it's possible to annotate this
  // properly now due to limitations in the clang thread annotation analysis.
  Buffer::OwnedImpl about_to_write_buffer_; // This buffer is used only by the flush thread. Data
                                            // is moved from flush_buffer_ under lock, and then
                                            // the lock is released so that flush_buffer_ can
                                            // continue to fill. This buffer is then used for the
                                            // final write to disk.
  Event::TimerPtr flush_timer_;
  Thread::ThreadFactory& thread_factory_;
  const std::chrono::milliseconds flush_interval_msec_; // Time interval buffer gets flushed no
                                                        // matter if it reached the MIN_FLUSH_SIZE
                                                        // or not.
  const uint64_t min_flush_size_{
      64 * 1024}; // Minimum size before the flush thread will be told to flush.
  AccessLogFileStats& stats_;
};

} // namespace AccessLog
} // namespace Envoy