Bug 962262 - Profiler - Use float instead of double to pack circular buffer. r=benwa
authorViktor Stanchev <vstanchev@mozilla.com>
Thu, 10 Apr 2014 10:52:23 -0400
changeset 178437 4743c6a40048186d9a794ffeaf9036b9ee2e4d29
parent 178436 90a1ad39c6adbb32a9954de2f7d4aba70700f264
child 178438 1515ebdea6768197428fd998cbbaf458b0187209
push id26586
push usercbook@mozilla.com
push dateTue, 15 Apr 2014 13:08:13 +0000
treeherdermozilla-central@56da72c95d48 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenwa
bugs962262
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 962262 - Profiler - Use float instead of double to pack circular buffer. r=benwa
tools/profiler/BreakpadSampler.cpp
tools/profiler/ProfileEntry.cpp
tools/profiler/ProfileEntry.h
tools/profiler/TableTicker.cpp
--- a/tools/profiler/BreakpadSampler.cpp
+++ b/tools/profiler/BreakpadSampler.cpp
@@ -234,22 +234,22 @@ void populateBuffer(UnwinderThreadBuffer
   if (recordSample) {    
     // add a "flush now" hint
     utb__addEntry( utb, ProfileEntry('h'/*hint*/, 'F'/*flush*/) );
   }
 
   // Add any extras
   if (!sLastTracerEvent.IsNull() && sample) {
     TimeDuration delta = sample->timestamp - sLastTracerEvent;
-    utb__addEntry( utb, ProfileEntry('r', delta.ToMilliseconds()) );
+    utb__addEntry( utb, ProfileEntry('r', static_cast<float>(delta.ToMilliseconds())) );
   }
 
   if (sample) {
     TimeDuration delta = sample->timestamp - sStartTime;
-    utb__addEntry( utb, ProfileEntry('t', delta.ToMilliseconds()) );
+    utb__addEntry( utb, ProfileEntry('t', static_cast<float>(delta.ToMilliseconds())) );
   }
 
   if (sLastFrameNumber != sFrameNumber) {
     utb__addEntry( utb, ProfileEntry('f', sFrameNumber) );
     sLastFrameNumber = sFrameNumber;
   }
 
   /* So now we have, in |utb|, the complete set of entries we want to
--- a/tools/profiler/ProfileEntry.cpp
+++ b/tools/profiler/ProfileEntry.cpp
@@ -38,17 +38,17 @@ ProfileEntry::ProfileEntry(char aTagName
   , mTagName(aTagName)
 { }
 
 ProfileEntry::ProfileEntry(char aTagName, void *aTagPtr)
   : mTagPtr(aTagPtr)
   , mTagName(aTagName)
 { }
 
-ProfileEntry::ProfileEntry(char aTagName, double aTagFloat)
+ProfileEntry::ProfileEntry(char aTagName, float aTagFloat)
   : mTagFloat(aTagFloat)
   , mTagName(aTagName)
 { }
 
 ProfileEntry::ProfileEntry(char aTagName, uintptr_t aTagOffset)
   : mTagOffset(aTagOffset)
   , mTagName(aTagName)
 { }
@@ -468,17 +468,17 @@ void ThreadProfile::DuplicateLastSample(
     // Found the start of the last entry at position i
     if (mEntries[readPos].mTagName == 's') {
       int copyEndIdx = mWritePos;
       // Go through the whole entry and duplicate it using a simple state machine
       for (;readPos != copyEndIdx; readPos = (readPos + 1) % mEntrySize) {
         switch (mEntries[readPos].mTagName) {
           // Copy with new time
           case 't':
-            addTag(ProfileEntry('t', (mozilla::TimeStamp::Now() - sStartTime).ToMilliseconds()));
+            addTag(ProfileEntry('t', static_cast<float>((mozilla::TimeStamp::Now() - sStartTime).ToMilliseconds())));
             break;
           // Don't copy markers
           case 'm':
             break;
           // Copy anything else we don't know about
           // L, B, S, m, c, s, d, l, f, h, r, t, p
           default:
             addTag(mEntries[readPos]);
--- a/tools/profiler/ProfileEntry.h
+++ b/tools/profiler/ProfileEntry.h
@@ -21,17 +21,17 @@ class ProfileEntry
 {
 public:
   ProfileEntry();
 
   // aTagData must not need release (i.e. be a string from the text segment)
   ProfileEntry(char aTagName, const char *aTagData);
   ProfileEntry(char aTagName, void *aTagPtr);
   ProfileEntry(char aTagName, ProfilerMarker *aTagMarker);
-  ProfileEntry(char aTagName, double aTagFloat);
+  ProfileEntry(char aTagName, float aTagFloat);
   ProfileEntry(char aTagName, uintptr_t aTagOffset);
   ProfileEntry(char aTagName, Address aTagAddress);
   ProfileEntry(char aTagName, int aTagLine);
   ProfileEntry(char aTagName, char aTagChar);
   friend std::ostream& operator<<(std::ostream& stream, const ProfileEntry& entry);
   bool is_ent_hint(char hintChar);
   bool is_ent_hint();
   bool is_ent(char tagName);
@@ -46,17 +46,17 @@ public:
 
 private:
   friend class ThreadProfile;
   union {
     const char* mTagData;
     char        mTagChars[sizeof(void*)];
     void*       mTagPtr;
     ProfilerMarker* mTagMarker;
-    double      mTagFloat;
+    float       mTagFloat;
     Address     mTagAddress;
     uintptr_t   mTagOffset;
     int         mTagLine;
     char        mTagChar;
   };
   char mTagName;
 };
 
--- a/tools/profiler/TableTicker.cpp
+++ b/tools/profiler/TableTicker.cpp
@@ -112,17 +112,17 @@ typename Builder::Object TableTicker::Ge
 
   b.DefineProperty(meta, "version", 2);
   b.DefineProperty(meta, "interval", interval());
   b.DefineProperty(meta, "stackwalk", mUseStackWalk);
   b.DefineProperty(meta, "jank", mJankOnly);
   b.DefineProperty(meta, "processType", XRE_GetProcessType());
 
   TimeDuration delta = TimeStamp::Now() - sStartTime;
-  b.DefineProperty(meta, "startTime", PR_Now()/1000.0 - delta.ToMilliseconds());
+  b.DefineProperty(meta, "startTime", static_cast<float>(PR_Now()/1000.0 - delta.ToMilliseconds()));
 
   nsresult res;
   nsCOMPtr<nsIHttpProtocolHandler> http = do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http", &res);
   if (!NS_FAILED(res)) {
     nsAutoCString string;
 
     res = http->GetPlatform(string);
     if (!NS_FAILED(res))
@@ -634,27 +634,27 @@ void TableTicker::InplaceTick(TickSample
   doSampleStackTrace(stack, currThreadProfile, mAddLeafAddresses ? sample : nullptr);
 #endif
 
   if (recordSample)
     currThreadProfile.flush();
 
   if (!sLastTracerEvent.IsNull() && sample && currThreadProfile.IsMainThread()) {
     TimeDuration delta = sample->timestamp - sLastTracerEvent;
-    currThreadProfile.addTag(ProfileEntry('r', delta.ToMilliseconds()));
+    currThreadProfile.addTag(ProfileEntry('r', static_cast<float>(delta.ToMilliseconds())));
   }
 
   if (sample) {
     TimeDuration delta = sample->timestamp - sStartTime;
-    currThreadProfile.addTag(ProfileEntry('t', delta.ToMilliseconds()));
+    currThreadProfile.addTag(ProfileEntry('t', static_cast<float>(delta.ToMilliseconds())));
   }
 
 #if defined(XP_WIN)
   if (powerSample) {
-    currThreadProfile.addTag(ProfileEntry('p', mIntelPowerGadget->GetTotalPackagePowerInWatts()));
+    currThreadProfile.addTag(ProfileEntry('p', static_cast<float>(mIntelPowerGadget->GetTotalPackagePowerInWatts())));
   }
 #endif
 
   if (sLastFrameNumber != sFrameNumber) {
     currThreadProfile.addTag(ProfileEntry('f', sFrameNumber));
     sLastFrameNumber = sFrameNumber;
   }
 }