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

Unified Diff: src/IceGlobalContext.h

Issue 887213002: Subzero: Fix stats collection and output for multithreading. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Reduce the number of TLS lookups Created 5 years, 11 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 | « no previous file | src/IceGlobalContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceGlobalContext.h
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index 04f08a2dbffa3191633fb39343b9e6e03f1ef1e0..0a1ecccd29badf0e17a8da5bf767c6be712c6ab4 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -73,6 +73,13 @@ class GlobalContext {
void updateFrameBytes(uint32_t Bytes) { FrameBytes += Bytes; }
void updateSpills() { ++Spills; }
void updateFills() { ++Fills; }
+ void add(const CodeStats &Other) {
+ InstructionsEmitted += Other.InstructionsEmitted;
+ RegistersSaved += Other.RegistersSaved;
+ FrameBytes += Other.FrameBytes;
+ Spills += Other.Spills;
+ Fills += Other.Fills;
+ }
void dump(const IceString &Name, Ostream &Str);
private:
@@ -121,6 +128,7 @@ class GlobalContext {
public:
ThreadContext() {}
CodeStats StatsFunction;
+ CodeStats StatsCumulative;
TimerList Timers;
};
@@ -209,32 +217,37 @@ public:
void statsUpdateEmitted(uint32_t InstCount) {
if (!ALLOW_DUMP || !getFlags().DumpStats)
return;
- ICE_TLS_GET_FIELD(TLS)->StatsFunction.updateEmitted(InstCount);
- getStatsCumulative()->updateEmitted(InstCount);
+ auto TLS = ICE_TLS_GET_FIELD(TLS);
JF 2015/01/31 05:48:38 auto *TLS = ...;
Jim Stichnoth 2015/01/31 16:42:28 Done, took it one step further... My original ide
+ TLS->StatsFunction.updateEmitted(InstCount);
+ TLS->StatsCumulative.updateEmitted(InstCount);
}
void statsUpdateRegistersSaved(uint32_t Num) {
if (!ALLOW_DUMP || !getFlags().DumpStats)
return;
- ICE_TLS_GET_FIELD(TLS)->StatsFunction.updateRegistersSaved(Num);
- getStatsCumulative()->updateRegistersSaved(Num);
+ auto TLS = ICE_TLS_GET_FIELD(TLS);
+ TLS->StatsFunction.updateRegistersSaved(Num);
+ TLS->StatsCumulative.updateRegistersSaved(Num);
}
void statsUpdateFrameBytes(uint32_t Bytes) {
if (!ALLOW_DUMP || !getFlags().DumpStats)
return;
- ICE_TLS_GET_FIELD(TLS)->StatsFunction.updateFrameBytes(Bytes);
- getStatsCumulative()->updateFrameBytes(Bytes);
+ auto TLS = ICE_TLS_GET_FIELD(TLS);
+ TLS->StatsFunction.updateFrameBytes(Bytes);
+ TLS->StatsCumulative.updateFrameBytes(Bytes);
}
void statsUpdateSpills() {
if (!ALLOW_DUMP || !getFlags().DumpStats)
return;
- ICE_TLS_GET_FIELD(TLS)->StatsFunction.updateSpills();
- getStatsCumulative()->updateSpills();
+ auto TLS = ICE_TLS_GET_FIELD(TLS);
+ TLS->StatsFunction.updateSpills();
+ TLS->StatsCumulative.updateSpills();
}
void statsUpdateFills() {
if (!ALLOW_DUMP || !getFlags().DumpStats)
return;
- ICE_TLS_GET_FIELD(TLS)->StatsFunction.updateFills();
- getStatsCumulative()->updateFills();
+ auto TLS = ICE_TLS_GET_FIELD(TLS);
+ TLS->StatsFunction.updateFills();
+ TLS->StatsCumulative.updateFills();
}
// These are predefined TimerStackIdT values.
@@ -296,6 +309,13 @@ public:
for (ThreadContext *TLS : AllThreadContexts)
Timers->mergeFrom(TLS->Timers);
}
+ if (ALLOW_DUMP) {
+ // Do a separate loop over AllThreadContexts to avoid holding
+ // two locks at once.
+ auto Stats = getStatsCumulative();
+ for (ThreadContext *TLS : AllThreadContexts)
+ Stats->add(TLS->StatsCumulative);
+ }
}
// Translation thread startup routine.
« no previous file with comments | « no previous file | src/IceGlobalContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698