Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Unified Diff: src/log-utils.h

Issue 125114: Involve more log compression techniques. (Closed)
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/log.cc ('k') | src/log-utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log-utils.h
diff --git a/src/log-utils.h b/src/log-utils.h
index af788d0ded57fb912d5b95927aa7282318d119f4..fe6f01cac65d194310583cf03327c7c5b77f6823 100644
--- a/src/log-utils.h
+++ b/src/log-utils.h
@@ -88,48 +88,6 @@ class LogDynamicBuffer {
};
-// An utility class for performing backward reference compression
-// of string ends. It operates using a window of previous strings.
-class LogRecordCompressor {
- public:
- // 'window_size' is the size of backward lookup window.
- // 'start_pos' is the length of string prefix that must be left uncompressed.
- LogRecordCompressor(int window_size, int start_pos)
- : buffer_(window_size), start_pos_(start_pos), curr_(-1), prev_(-1) {
- // Must have place for the current record and the previous.
- ASSERT(window_size >= 2);
- }
- ~LogRecordCompressor();
-
- // Fills vector with a compressed version of the previous record.
- // Returns false if there is no previous record.
- bool RetrievePreviousCompressed(Vector<char>* prev_record);
-
- // Stores a record if it differs from a previous one (or there's no previous).
- // Returns true, if the record has been stored.
- bool Store(const Vector<const char>& record);
-
- private:
- // Record field separator. It is assumed that it can't appear
- // inside a field (a simplified version of CSV format).
- static const char kFieldSeparator = ',';
-
- // Formatting string for back references.
- static const char* kBackwardReferenceFormat;
-
- // A boundary value. If current record only differs in
- // kUncompressibleBound chars, don't compress it.
- // The value must be greater than the length of maximum
- // projected backward reference length.
- static const intptr_t kUncompressibleBound = 10;
-
- ScopedVector< Vector<const char> > buffer_;
- const int start_pos_;
- int curr_;
- int prev_;
-};
-
-
// Functions and data for performing output of log messages.
class Log : public AllStatic {
public:
@@ -156,9 +114,6 @@ class Log : public AllStatic {
return !is_stopped_ && (output_handle_ != NULL || output_buffer_ != NULL);
}
- // Size of buffer used for record compression.
- static const int kRecordCompressorWindow = 6;
-
private:
typedef int (*WritePtr)(const char* msg, int length);
@@ -214,12 +169,51 @@ class Log : public AllStatic {
// mutex_ should be acquired before using it.
static char* message_buffer_;
- // An utility object for compressing repeated parts of records.
- static LogRecordCompressor* record_compressor_;
+ friend class LogMessageBuilder;
+ friend class LogRecordCompressor;
+};
+
- static const char* kCompressedTickEventName;
+// An utility class for performing backward reference compression
+// of string ends. It operates using a window of previous strings.
+class LogRecordCompressor {
+ public:
+ // 'window_size' is the size of backward lookup window.
+ explicit LogRecordCompressor(int window_size)
+ : buffer_(window_size + kNoCompressionWindowSize),
+ kMaxBackwardReferenceSize(
+ GetBackwardReferenceSize(window_size, Log::kMessageBufferSize)),
+ curr_(-1), prev_(-1) {
+ }
- friend class LogMessageBuilder;
+ ~LogRecordCompressor();
+
+ // Fills vector with a compressed version of the previous record.
+ // Returns false if there is no previous record.
+ bool RetrievePreviousCompressed(Vector<char>* prev_record);
+
+ // Stores a record if it differs from a previous one (or there's no previous).
+ // Returns true, if the record has been stored.
+ bool Store(const Vector<const char>& record);
+
+ private:
+ // The minimum size of a buffer: a place needed for the current and
+ // the previous record. Since there is no place for precedessors of a previous
+ // record, it can't be compressed at all.
+ static const int kNoCompressionWindowSize = 2;
+
+ // Formatting strings for back references.
+ static const char* kLineBackwardReferenceFormat;
+ static const char* kBackwardReferenceFormat;
+
+ static int GetBackwardReferenceSize(int distance, int pos);
+
+ static void PrintBackwardReference(Vector<char> dest, int distance, int pos);
+
+ ScopedVector< Vector<const char> > buffer_;
+ const int kMaxBackwardReferenceSize;
+ int curr_;
+ int prev_;
};
@@ -244,20 +238,28 @@ class LogMessageBuilder BASE_EMBEDDED {
// Append a heap string.
void Append(String* str);
+ // Appends an address, compressing it if needed by offsetting
+ // from Logger::last_address_.
+ void AppendAddress(Address addr);
+
+ // Appends an address, compressing it if needed.
+ void AppendAddress(Address addr, Address bias);
+
void AppendDetailed(String* str, bool show_impl_info);
// Stores log message into compressor, returns true if the message
- // was stored (i.e. doesn't repeat the previous one). If log compression is
- // disabled, does nothing and returns true.
- bool StoreInCompressor();
+ // was stored (i.e. doesn't repeat the previous one).
+ bool StoreInCompressor(LogRecordCompressor* compressor);
// Sets log message to a previous version of compressed message.
- // Returns false, if there is no previous message. If log compression
- // is disabled, does nothing and retuns true.
- bool RetrieveCompressedPrevious() { return RetrieveCompressedPrevious(""); }
+ // Returns false, if there is no previous message.
+ bool RetrieveCompressedPrevious(LogRecordCompressor* compressor) {
+ return RetrieveCompressedPrevious(compressor, "");
+ }
// Does the same at the version without arguments, and sets a prefix.
- bool RetrieveCompressedPrevious(const char* prefix);
+ bool RetrieveCompressedPrevious(LogRecordCompressor* compressor,
+ const char* prefix);
// Write the log message to the log file currently opened.
void WriteToLogFile();
« no previous file with comments | « src/log.cc ('k') | src/log-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698