diff options
author | Leyla Farazha <leyla@lindenlab.com> | 2011-08-12 14:53:25 -0700 |
---|---|---|
committer | Leyla Farazha <leyla@lindenlab.com> | 2011-08-12 14:53:25 -0700 |
commit | 10ec0049125317d5c0bdd1bf89b96a54a9b2d873 (patch) | |
tree | 97efa1a6731aef7e703e1a6ca2eaa4a01dbb6fa8 /indra/llcommon | |
parent | e69efc8369a65008d41155717761fbaec0e309c5 (diff) | |
parent | 25f1653ca0a25c73b3c0649ee5bb7c65e5378eac (diff) |
merge from viewer-experience
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llsdserialize.cpp | 2 | ||||
-rw-r--r-- | indra/llcommon/llsdserialize_xml.cpp | 12 | ||||
-rw-r--r-- | indra/llcommon/llsys.cpp | 234 | ||||
-rw-r--r-- | indra/llcommon/llversionviewer.h | 6 |
4 files changed, 78 insertions, 176 deletions
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp index bf62600514..6610daa1e0 100644 --- a/indra/llcommon/llsdserialize.cpp +++ b/indra/llcommon/llsdserialize.cpp @@ -313,8 +313,10 @@ LLSDParser::LLSDParser() LLSDParser::~LLSDParser() { } +LLFastTimer::DeclareTimer FTM_SD_PARSE("LLSD Parsing"); S32 LLSDParser::parse(std::istream& istr, LLSD& data, S32 max_bytes) { + LLFastTimer _(FTM_SD_PARSE); mCheckLimits = (LLSDSerialize::SIZE_UNLIMITED == max_bytes) ? false : true; mMaxBytesLeft = max_bytes; return doParse(istr, data); diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp index c5a7c6fc15..d8213c4477 100644 --- a/indra/llcommon/llsdserialize_xml.cpp +++ b/indra/llcommon/llsdserialize_xml.cpp @@ -354,6 +354,7 @@ static unsigned get_till_eol(std::istream& input, char *buf, unsigned bufsize) return count; } +LLFastTimer::DeclareTimer FTM_SD_PARSE_READ_STREAM("LLSD Read Stream"); S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data) { XML_Status status; @@ -373,10 +374,13 @@ S32 LLSDXMLParser::Impl::parse(std::istream& input, LLSD& data) { break; } - count = get_till_eol(input, (char *)buffer, BUFFER_SIZE); - if (!count) - { - break; + { LLFastTimer _(FTM_SD_PARSE_READ_STREAM); + + count = get_till_eol(input, (char *)buffer, BUFFER_SIZE); + if (!count) + { + break; + } } status = XML_ParseBuffer(mParser, count, false); diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 99e61433c6..d781687175 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -68,9 +68,11 @@ using namespace llsd; # include <sys/utsname.h> # include <stdint.h> # include <Carbon/Carbon.h> -# include <sys/wait.h> -# include <string.h> # include <stdexcept> +# include <mach/host_info.h> +# include <mach/mach_host.h> +# include <mach/task.h> +# include <mach/task_info.h> #elif LL_LINUX # include <errno.h> # include <sys/utsname.h> @@ -990,194 +992,88 @@ LLSD LLMemoryInfo::loadStatsMap() stats.add("PrivateUsage KB", pmem.PrivateUsage/1024); #elif LL_DARWIN - uint64_t phys = 0; - size_t len = sizeof(phys); + const vm_size_t pagekb(vm_page_size / 1024); + + // + // Collect the vm_stat's + // - if (sysctlbyname("hw.memsize", &phys, &len, NULL, 0) == 0) - { - stats.add("Total Physical KB", phys/1024); - } - else { - LL_WARNS("LLMemoryInfo") << "Unable to collect hw.memsize memory information" << LL_ENDL; - } + vm_statistics_data_t vmstat; + mach_msg_type_number_t vmstatCount = HOST_VM_INFO_COUNT; - FILE* pout = popen("vm_stat 2>&1", "r"); - if (! pout) // popen() couldn't run vm_stat + if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t) &vmstat, &vmstatCount) != KERN_SUCCESS) { - // Save errno right away. - int popen_errno(errno); - LL_WARNS("LLMemoryInfo") << "Unable to collect vm_stat memory information: "; - char buffer[256]; - if (0 == strerror_r(popen_errno, buffer, sizeof(buffer))) - { - LL_CONT << buffer; + LL_WARNS("LLMemoryInfo") << "Unable to collect memory information" << LL_ENDL; } else { - LL_CONT << "errno " << popen_errno; + stats.add("Pages free KB", pagekb * vmstat.free_count); + stats.add("Pages active KB", pagekb * vmstat.active_count); + stats.add("Pages inactive KB", pagekb * vmstat.inactive_count); + stats.add("Pages wired KB", pagekb * vmstat.wire_count); + + stats.add("Pages zero fill", vmstat.zero_fill_count); + stats.add("Page reactivations", vmstat.reactivations); + stats.add("Page-ins", vmstat.pageins); + stats.add("Page-outs", vmstat.pageouts); + + stats.add("Faults", vmstat.faults); + stats.add("Faults copy-on-write", vmstat.cow_faults); + + stats.add("Cache lookups", vmstat.lookups); + stats.add("Cache hits", vmstat.hits); + + stats.add("Page purgeable count", vmstat.purgeable_count); + stats.add("Page purges", vmstat.purges); + + stats.add("Page speculative reads", vmstat.speculative_count); } - LL_CONT << LL_ENDL; } - else // popen() launched vm_stat - { - // Mach Virtual Memory Statistics: (page size of 4096 bytes) - // Pages free: 462078. - // Pages active: 142010. - // Pages inactive: 220007. - // Pages wired down: 159552. - // "Translation faults": 220825184. - // Pages copy-on-write: 2104153. - // Pages zero filled: 167034876. - // Pages reactivated: 65153. - // Pageins: 2097212. - // Pageouts: 41759. - // Object cache: 841598 hits of 7629869 lookups (11% hit rate) - - // Intentionally don't pass the boost::no_except flag. These - // boost::regex objects are constructed with string literals, so they - // should be valid every time. If they become invalid, we WANT an - // exception, hopefully even before the dev checks in. - boost::regex pagesize_rx("\\(page size of ([0-9]+) bytes\\)"); - boost::regex stat_rx("(.+): +([0-9]+)\\."); - boost::regex cache_rx("Object cache: ([0-9]+) hits of ([0-9]+) lookups " - "\\(([0-9]+)% hit rate\\)"); - boost::cmatch matched; - LLSD::Integer pagesizekb(4096/1024); - - // Here 'pout' is vm_stat's stdout. Search it for relevant data. - char line[100]; - line[sizeof(line)-1] = '\0'; - while (fgets(line, sizeof(line)-1, pout)) + + // + // Collect the misc task info + // + { - size_t linelen(strlen(line)); - // Truncate any trailing newline - if (line[linelen - 1] == '\n') - { - line[--linelen] = '\0'; - } - LL_DEBUGS("LLMemoryInfo") << line << LL_ENDL; - if (regex_search_no_exc(line, matched, pagesize_rx)) - { - // "Mach Virtual Memory Statistics: (page size of 4096 bytes)" - std::string pagesize_str(matched[1].first, matched[1].second); - try - { - // Reasonable to assume that pagesize will always be a - // multiple of 1Kb? - pagesizekb = boost::lexical_cast<LLSD::Integer>(pagesize_str)/1024; - } - catch (const boost::bad_lexical_cast&) - { - LL_WARNS("LLMemoryInfo") << "couldn't parse '" << pagesize_str - << "' in vm_stat line: " << line << LL_ENDL; - continue; - } - stats.add("page size", pagesizekb); - } - else if (regex_match_no_exc(line, matched, stat_rx)) - { - // e.g. "Pages free: 462078." - // Strip double-quotes off certain statistic names - const char *key_begin(matched[1].first), *key_end(matched[1].second); - if (key_begin[0] == '"' && key_end[-1] == '"') - { - ++key_begin; - --key_end; - } - LLSD::String key(key_begin, key_end); - LLSD::String value_str(matched[2].first, matched[2].second); - LLSD::Integer value(0); - try - { - value = boost::lexical_cast<LLSD::Integer>(value_str); - } - catch (const boost::bad_lexical_cast&) - { - LL_WARNS("LLMemoryInfo") << "couldn't parse '" << value_str - << "' in vm_stat line: " << line << LL_ENDL; - continue; - } - // Store this statistic. - stats.add(key, value); - // Is this in units of pages? If so, convert to Kb. - static const LLSD::String pages("Pages "); - if (key.substr(0, pages.length()) == pages) - { - // Synthesize a new key with kb in place of Pages - LLSD::String kbkey("kb "); - kbkey.append(key.substr(pages.length())); - stats.add(kbkey, value * pagesizekb); - } - } - else if (regex_match_no_exc(line, matched, cache_rx)) - { - // e.g. "Object cache: 841598 hits of 7629869 lookups (11% hit rate)" - static const char* cache_keys[] = { "cache hits", "cache lookups", "cache hit%" }; - std::vector<LLSD::Integer> cache_values; - for (size_t i = 0; i < (sizeof(cache_keys)/sizeof(cache_keys[0])); ++i) - { - LLSD::String value_str(matched[i+1].first, matched[i+1].second); - LLSD::Integer value(0); - try - { - value = boost::lexical_cast<LLSD::Integer>(value_str); - } - catch (boost::bad_lexical_cast&) + task_events_info_data_t taskinfo; + unsigned taskinfoSize = sizeof(taskinfo); + + if (task_info(mach_task_self(), TASK_EVENTS_INFO, (task_info_t) &taskinfo, &taskinfoSize) != KERN_SUCCESS) { - LL_WARNS("LLMemoryInfo") << "couldn't parse '" << value_str - << "' in vm_stat line: " << line << LL_ENDL; - continue; - } - stats.add(cache_keys[i], value); - } + LL_WARNS("LLMemoryInfo") << "Unable to collect task information" << LL_ENDL; } else { - LL_WARNS("LLMemoryInfo") << "unrecognized vm_stat line: " << line << LL_ENDL; + stats.add("Task page-ins", taskinfo.pageins); + stats.add("Task copy-on-write faults", taskinfo.cow_faults); + stats.add("Task messages sent", taskinfo.messages_sent); + stats.add("Task messages received", taskinfo.messages_received); + stats.add("Task mach system call count", taskinfo.syscalls_mach); + stats.add("Task unix system call count", taskinfo.syscalls_unix); + stats.add("Task context switch count", taskinfo.csw); } - } - int status(pclose(pout)); - if (status == -1) // pclose() couldn't retrieve rc + } + + // + // Collect the basic task info + // + { - // Save errno right away. - int pclose_errno(errno); - // The ECHILD error happens so frequently that unless filtered, - // the warning below spams the log file. This is too bad, because - // sometimes the logic above fails to produce any output derived - // from vm_stat, but we've been unable to observe any specific - // error indicating the problem. - if (pclose_errno != ECHILD) + task_basic_info_64_data_t taskinfo; + unsigned taskinfoSize = sizeof(taskinfo); + + if (task_info(mach_task_self(), TASK_BASIC_INFO_64, (task_info_t) &taskinfo, &taskinfoSize) != KERN_SUCCESS) { - LL_WARNS("LLMemoryInfo") << "Unable to obtain vm_stat termination code: "; - char buffer[256]; - if (0 == strerror_r(pclose_errno, buffer, sizeof(buffer))) - { - LL_CONT << buffer; + LL_WARNS("LLMemoryInfo") << "Unable to collect task information" << LL_ENDL; } else { - LL_CONT << "errno " << pclose_errno; - } - LL_CONT << LL_ENDL; - } - } - else // pclose() retrieved rc; analyze - { - if (WIFEXITED(status)) - { - int rc(WEXITSTATUS(status)); - if (rc != 0) - { - LL_WARNS("LLMemoryInfo") << "vm_stat terminated with rc " << rc << LL_ENDL; - } - } - else if (WIFSIGNALED(status)) - { - LL_WARNS("LLMemoryInfo") << "vm_stat terminated by signal " << WTERMSIG(status) - << LL_ENDL; - } + stats.add("Basic suspend count", taskinfo.suspend_count); + stats.add("Basic virtual memory KB", taskinfo.virtual_size / 1024); + stats.add("Basic resident memory KB", taskinfo.resident_size / 1024); + stats.add("Basic new thread policy", taskinfo.policy); } } diff --git a/indra/llcommon/llversionviewer.h b/indra/llcommon/llversionviewer.h index f98a5398c3..27b1bce60c 100644 --- a/indra/llcommon/llversionviewer.h +++ b/indra/llcommon/llversionviewer.h @@ -27,9 +27,9 @@ #ifndef LL_LLVERSIONVIEWER_H #define LL_LLVERSIONVIEWER_H -const S32 LL_VERSION_MAJOR = 2; -const S32 LL_VERSION_MINOR = 8; -const S32 LL_VERSION_PATCH = 3; +const S32 LL_VERSION_MAJOR = 3; +const S32 LL_VERSION_MINOR = 0; +const S32 LL_VERSION_PATCH = 1; const S32 LL_VERSION_BUILD = 0; const char * const LL_CHANNEL = "Second Life Developer"; |