From 7f8ec9f142f34057fc10436f94ce420183cf75b8 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 29 Jun 2011 20:35:44 -0400 Subject: CHOP-753: Introduce LLSD access to LLMemoryInfo ** BROKEN ** This is known not to compile on Mac yet; checking in to concurrently work on Linux-specific code. --- indra/llcommon/llsys.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'indra/llcommon/llsys.h') diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 41a4f25000..5b44757e08 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -36,6 +36,7 @@ // llinfos << info << llendl; // +#include "llsd.h" #include #include @@ -117,6 +118,33 @@ public: //get the available memory infomation in KiloBytes. static void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb); + + // Retrieve a map of memory statistics. The keys of the map are platform- + // dependent. The values are in kilobytes. + LLSD getStatsMap() const; + + // Retrieve memory statistics: an array of pair arrays [name, value]. This + // is the same data as presented in getStatsMap(), but it preserves the + // order in which we retrieved it from the OS in case that's useful. The + // set of statistics names is platform-dependent. The values are in + // kilobytes to try to avoid integer overflow. + LLSD getStatsArray() const; + + // Re-fetch memory data (as reported by stream() and getStats*()) from the + // system. Normally this is fetched at construction time. Return (*this) + // to permit usage of the form: + // @code + // LLMemoryInfo info; + // ... + // info.refresh().getStatsArray(); + // @endcode + LLMemoryInfo& refresh(); + +private: + // Internally, we store memory stats as for getStatsArray(). It's + // straightforward to convert that to getStatsMap() form, less so to + // reconstruct the original order when converting the other way. + LLSD mData; }; -- cgit v1.2.3 From 01607fe418b19e7439020047c270c0e7c86725e7 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 30 Jun 2011 11:50:54 -0400 Subject: CHOP-753: Reduce redundancy in LLMemoryInfo. Recast stream() to display data from LLSD array rather than reinvoking OS operations used to capture it. Make refresh() cache LLSD data in map form as well as array; fetch items from that in a few places to avoid going back to OS. --- indra/llcommon/llsys.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/llsys.h') diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 5b44757e08..8565bfa0b9 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -141,10 +141,12 @@ public: LLMemoryInfo& refresh(); private: - // Internally, we store memory stats as for getStatsArray(). It's - // straightforward to convert that to getStatsMap() form, less so to - // reconstruct the original order when converting the other way. - LLSD mData; + // Memory stats for getStatsArray(). It's straightforward to convert that + // to getStatsMap() form, less so to reconstruct the original order when + // converting the other way. + LLSD mStatsArray; + // Memory stats for getStatsMap(). + LLSD mStatsMap; }; -- cgit v1.2.3 From abf50e8c7d3cf0bab46286f4b300c7d3be976775 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 30 Jun 2011 13:57:11 -0400 Subject: CHOP-753: Fix compile errors in LLMemoryInfo Windows-specific code. --- indra/llcommon/llsys.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llcommon/llsys.h') diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 8565bfa0b9..7fcb050ed0 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -141,6 +141,10 @@ public: LLMemoryInfo& refresh(); private: + // These methods are used to set mStatsArray and mStatsMap. + static LLSD loadStatsArray(); + static LLSD loadStatsMap(const LLSD&); + // Memory stats for getStatsArray(). It's straightforward to convert that // to getStatsMap() form, less so to reconstruct the original order when // converting the other way. -- cgit v1.2.3 From ed648b1f08a191250c5c37f831280c31950b502a Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 12 Jul 2011 20:14:39 -0400 Subject: CHOP-753: Eliminate redundant array-of-pair-arrays in LLMemoryInfo. (per Monty code review) The notion of storing LLMemoryInfo data both as an LLSD::Map and an LLSD::Array of pair arrays arose from a (possibly misguided) desire to continue producing stats output into the viewer log in the same order it always used to be produced. There is no evidence that anyone cares about the order of those stats in the log; there is no other use case for preserving order. At Monty's recommendation, eliminate generating and storing the array-of-pair-arrays form: directly store LLSD::Map. --- indra/llcommon/llsys.h | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'indra/llcommon/llsys.h') diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h index 7fcb050ed0..739e795d3a 100644 --- a/indra/llcommon/llsys.h +++ b/indra/llcommon/llsys.h @@ -120,35 +120,23 @@ public: static void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb); // Retrieve a map of memory statistics. The keys of the map are platform- - // dependent. The values are in kilobytes. + // dependent. The values are in kilobytes to try to avoid integer overflow. LLSD getStatsMap() const; - // Retrieve memory statistics: an array of pair arrays [name, value]. This - // is the same data as presented in getStatsMap(), but it preserves the - // order in which we retrieved it from the OS in case that's useful. The - // set of statistics names is platform-dependent. The values are in - // kilobytes to try to avoid integer overflow. - LLSD getStatsArray() const; - - // Re-fetch memory data (as reported by stream() and getStats*()) from the + // Re-fetch memory data (as reported by stream() and getStatsMap()) from the // system. Normally this is fetched at construction time. Return (*this) // to permit usage of the form: // @code // LLMemoryInfo info; // ... - // info.refresh().getStatsArray(); + // info.refresh().getStatsMap(); // @endcode LLMemoryInfo& refresh(); private: - // These methods are used to set mStatsArray and mStatsMap. - static LLSD loadStatsArray(); - static LLSD loadStatsMap(const LLSD&); - - // Memory stats for getStatsArray(). It's straightforward to convert that - // to getStatsMap() form, less so to reconstruct the original order when - // converting the other way. - LLSD mStatsArray; + // set mStatsMap + static LLSD loadStatsMap(); + // Memory stats for getStatsMap(). LLSD mStatsMap; }; -- cgit v1.2.3