Backed out changesets 819d7887fdc4 and 6a0397d889c9 (bug 1157870) for frequent e10s browser_compartments.js failures.

This commit is contained in:
Ryan VanderMeulen 2015-06-15 13:54:03 -04:00
parent 465c6d082c
commit e57c6682e8
10 changed files with 41 additions and 101 deletions

View File

@ -338,7 +338,7 @@ IterPerformanceStats(JSContext* cx,
continue;
}
if (!(*walker)(cx, group->data, group->uid, closure)) {
if (!(*walker)(cx, group->data, closure)) {
// Issue in callback
return false;
}

View File

@ -5448,9 +5448,6 @@ struct PerformanceGroup {
// Performance data for this group.
PerformanceData data;
// An id unique to this runtime.
const uint64_t uid;
// `true` if an instance of `AutoStopwatch` is already monitoring
// the performance of this performance group for this iteration
// of the event loop, `false` otherwise.
@ -5475,7 +5472,12 @@ struct PerformanceGroup {
stopwatch_ = nullptr;
}
explicit PerformanceGroup(JSContext* cx, void* key);
explicit PerformanceGroup(void* key)
: stopwatch_(nullptr)
, iteration_(0)
, key_(key)
, refCount_(0)
{ }
~PerformanceGroup()
{
MOZ_ASSERT(refCount_ == 0);
@ -5587,7 +5589,7 @@ extern JS_PUBLIC_API(PerformanceData*)
GetPerformanceData(JSRuntime*);
typedef bool
(PerformanceStatsWalker)(JSContext* cx, const PerformanceData& stats, uint64_t uid, void* closure);
(PerformanceStatsWalker)(JSContext* cx, const PerformanceData& stats, void* closure);
/**
* Extract the performance statistics.

View File

@ -955,7 +955,7 @@ js::PerformanceGroupHolder::getGroup(JSContext* cx)
group_ = ptr->value();
MOZ_ASSERT(group_);
} else {
group_ = runtime_->new_<PerformanceGroup>(cx, key);
group_ = runtime_->new_<PerformanceGroup>(key);
runtime_->stopwatch.groups_.add(ptr, key, group_);
}
@ -970,15 +970,6 @@ js::GetPerformanceData(JSRuntime* rt)
return &rt->stopwatch.performance;
}
js::PerformanceGroup::PerformanceGroup(JSContext* cx, void* key)
: uid(cx->runtime()->stopwatch.uniqueId())
, stopwatch_(nullptr)
, iteration_(0)
, key_(key)
, refCount_(0)
{
}
void
JS_SetCurrentPerfGroupCallback(JSRuntime *rt, JSCurrentPerfGroupCallback cb)
{

View File

@ -1517,7 +1517,6 @@ struct JSRuntime : public JS::shadow::Runtime,
, currentPerfGroupCallback(nullptr)
, isMonitoringJank_(false)
, isMonitoringCPOW_(false)
, idCounter_(0)
{ }
/**
@ -1571,13 +1570,6 @@ struct JSRuntime : public JS::shadow::Runtime,
return isMonitoringCPOW_;
}
/**
* Return a identifier for a group, unique to the runtime.
*/
uint64_t uniqueId() {
return idCounter_++;
}
// Some systems have non-monotonic clocks. While we cannot
// improve the precision, we can make sure that our measures
// are monotonic nevertheless. We do this by storing the
@ -1628,11 +1620,6 @@ struct JSRuntime : public JS::shadow::Runtime,
*/
bool isMonitoringJank_;
bool isMonitoringCPOW_;
/**
* A counter used to generate unique identifiers for groups.
*/
uint64_t idCounter_;
};
Stopwatch stopwatch;
};

View File

@ -120,7 +120,8 @@ let State = {
let newData = new Map();
let deltas = [];
for (let componentNew of snapshot.componentsData) {
let key = componentNew.groupId;
let {name, addonId, isSystem} = componentNew;
let key = JSON.stringify({name, addonId, isSystem});
let componentOld = State._componentsData.get(key);
deltas.push(componentNew.subtract(componentOld));
newData.set(key, componentNew);

View File

@ -42,7 +42,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "finalizer",
// and that we can release/close the probes it holds.
const FINALIZATION_TOPIC = "performancemonitor-finalize";
const PROPERTIES_META_IMMUTABLE = ["name", "addonId", "isSystem", "groupId"];
const PROPERTIES_META_IMMUTABLE = ["name", "addonId", "isSystem"];
const PROPERTIES_META = [...PROPERTIES_META_IMMUTABLE, "windowId", "title"];
/**

View File

@ -22,16 +22,8 @@
* All values are monotonic and are updated only when
* `nsIPerformanceStatsService.isStopwatchActive` is `true`.
*/
[scriptable, uuid(47f8d36d-1d67-43cb-befd-d2f4720ac568)]
[scriptable, uuid(b060d75d-55bc-4c82-a4ff-458fc5ab2a69)]
interface nsIPerformanceStats: nsISupports {
/**
* An identifier unique to the component.
*
* This identifier is somewhat human-readable to aid with debugging,
* but clients should not rely upon the format.
*/
readonly attribute AString groupId;
/**
* The name of the component:
* - for the process itself, "<process>";

View File

@ -22,23 +22,15 @@
#include "nsIDOMWindow.h"
#include "nsGlobalWindow.h"
#if defined(XP_WIN)
#include "Windows.h"
#else
#include <unistd.h>
#endif
class nsPerformanceStats: public nsIPerformanceStats {
public:
nsPerformanceStats(const nsAString& aName,
const nsAString& aGroupId,
const nsAString& aAddonId,
const nsAString& aTitle,
const uint64_t aWindowId,
const bool aIsSystem,
const js::PerformanceData& aPerformanceData)
: mName(aName)
, mGroupId(aGroupId)
, mAddonId(aAddonId)
, mTitle(aTitle)
, mWindowId(aWindowId)
@ -56,13 +48,7 @@ public:
return NS_OK;
};
/* readonly attribute AString groupId; */
NS_IMETHOD GetGroupId(nsAString& aGroupId) override {
aGroupId.Assign(mGroupId);
return NS_OK;
};
/* readonly attribute AString addonId; */
/* readonly attribute AString addon id; */
NS_IMETHOD GetAddonId(nsAString& aAddonId) override {
aAddonId.Assign(mAddonId);
return NS_OK;
@ -125,7 +111,6 @@ public:
private:
nsString mName;
nsString mGroupId;
nsString mAddonId;
nsString mTitle;
uint64_t mWindowId;
@ -146,7 +131,7 @@ public:
NS_DECL_NSIPERFORMANCESNAPSHOT
nsPerformanceSnapshot();
nsresult Init(JSContext*, uint64_t processId);
nsresult Init(JSContext*);
private:
virtual ~nsPerformanceSnapshot();
@ -160,22 +145,20 @@ private:
* entire process, rather than the statistics for a specific set of
* compartments.
*/
already_AddRefed<nsIPerformanceStats> ImportStats(JSContext* cx, const js::PerformanceData& data, uint64_t uid);
already_AddRefed<nsIPerformanceStats> ImportStats(JSContext* cx, const js::PerformanceData& data);
/**
* Callbacks for iterating through the `PerformanceStats` of a runtime.
*/
bool IterPerformanceStatsCallbackInternal(JSContext* cx, const js::PerformanceData& stats, uint64_t uid);
static bool IterPerformanceStatsCallback(JSContext* cx, const js::PerformanceData& stats, uint64_t uid, void* self);
bool IterPerformanceStatsCallbackInternal(JSContext* cx, const js::PerformanceData& stats);
static bool IterPerformanceStatsCallback(JSContext* cx, const js::PerformanceData& stats, void* self);
// If the context represents a window, extract the title and window ID.
// Otherwise, extract "" and 0.
static void GetWindowData(JSContext*,
nsString& title,
uint64_t* windowId);
void GetGroupId(JSContext*,
uint64_t uid,
nsString& groupId);
// If the context presents an add-on, extract the addon ID.
// Otherwise, extract "".
static void GetAddonId(JSContext*,
@ -189,7 +172,6 @@ private:
private:
nsCOMArray<nsIPerformanceStats> mComponentsData;
nsCOMPtr<nsIPerformanceStats> mProcessData;
uint64_t mProcessId;
};
NS_IMPL_ISUPPORTS(nsPerformanceSnapshot, nsIPerformanceSnapshot)
@ -251,22 +233,6 @@ nsPerformanceSnapshot::GetAddonId(JSContext*,
AssignJSFlatString(addonId, (JSFlatString*)jsid);
}
void
nsPerformanceSnapshot::GetGroupId(JSContext* cx,
uint64_t uid,
nsString& groupId)
{
JSRuntime* rt = JS_GetRuntime(cx);
uint64_t runtimeId = reinterpret_cast<uintptr_t>(rt);
groupId.AssignLiteral("process: ");
groupId.AppendInt(mProcessId);
groupId.AssignLiteral(", thread: ");
groupId.AppendInt(runtimeId);
groupId.AppendLiteral(", group: ");
groupId.AppendInt(uid);
}
/* static */ bool
nsPerformanceSnapshot::GetIsSystem(JSContext*,
JS::Handle<JSObject*> global)
@ -275,7 +241,7 @@ nsPerformanceSnapshot::GetIsSystem(JSContext*,
}
already_AddRefed<nsIPerformanceStats>
nsPerformanceSnapshot::ImportStats(JSContext* cx, const js::PerformanceData& performance, const uint64_t uid) {
nsPerformanceSnapshot::ImportStats(JSContext* cx, const js::PerformanceData& performance) {
JS::RootedObject global(cx, JS::CurrentGlobalOrNull(cx));
if (!global) {
@ -284,9 +250,6 @@ nsPerformanceSnapshot::ImportStats(JSContext* cx, const js::PerformanceData& per
return nullptr;
}
nsString groupId;
GetGroupId(cx, uid, groupId);
nsString addonId;
GetAddonId(cx, global, addonId);
@ -302,18 +265,18 @@ nsPerformanceSnapshot::ImportStats(JSContext* cx, const js::PerformanceData& per
bool isSystem = GetIsSystem(cx, global);
nsCOMPtr<nsIPerformanceStats> result =
new nsPerformanceStats(name, groupId, addonId, title, windowId, isSystem, performance);
new nsPerformanceStats(name, addonId, title, windowId, isSystem, performance);
return result.forget();
}
/*static*/ bool
nsPerformanceSnapshot::IterPerformanceStatsCallback(JSContext* cx, const js::PerformanceData& stats, const uint64_t uid, void* self) {
return reinterpret_cast<nsPerformanceSnapshot*>(self)->IterPerformanceStatsCallbackInternal(cx, stats, uid);
nsPerformanceSnapshot::IterPerformanceStatsCallback(JSContext* cx, const js::PerformanceData& stats, void* self) {
return reinterpret_cast<nsPerformanceSnapshot*>(self)->IterPerformanceStatsCallbackInternal(cx, stats);
}
bool
nsPerformanceSnapshot::IterPerformanceStatsCallbackInternal(JSContext* cx, const js::PerformanceData& stats, const uint64_t uid) {
nsCOMPtr<nsIPerformanceStats> result = ImportStats(cx, stats, uid);
nsPerformanceSnapshot::IterPerformanceStatsCallbackInternal(JSContext* cx, const js::PerformanceData& stats) {
nsCOMPtr<nsIPerformanceStats> result = ImportStats(cx, stats);
if (result) {
mComponentsData.AppendElement(result);
}
@ -322,15 +285,13 @@ nsPerformanceSnapshot::IterPerformanceStatsCallbackInternal(JSContext* cx, const
}
nsresult
nsPerformanceSnapshot::Init(JSContext* cx, uint64_t processId) {
mProcessId = processId;
nsPerformanceSnapshot::Init(JSContext* cx) {
js::PerformanceData processStats;
if (!js::IterPerformanceStats(cx, nsPerformanceSnapshot::IterPerformanceStatsCallback, &processStats, this)) {
return NS_ERROR_UNEXPECTED;
}
mProcessData = new nsPerformanceStats(NS_LITERAL_STRING("<process>"), // name
NS_LITERAL_STRING("<process:?>"), // group id
NS_LITERAL_STRING(""), // add-on id
NS_LITERAL_STRING(""), // title
0, // window id
@ -365,11 +326,6 @@ NS_IMETHODIMP nsPerformanceSnapshot::GetProcessData(nsIPerformanceStats * *aProc
NS_IMPL_ISUPPORTS(nsPerformanceStatsService, nsIPerformanceStatsService)
nsPerformanceStatsService::nsPerformanceStatsService()
#if defined(XP_WIN)
: mProcessId(GetCurrentProcessId())
#else
: mProcessId(getpid())
#endif
{
}
@ -411,7 +367,7 @@ NS_IMETHODIMP nsPerformanceStatsService::SetIsMonitoringJank(JSContext* cx, bool
NS_IMETHODIMP nsPerformanceStatsService::GetSnapshot(JSContext* cx, nsIPerformanceSnapshot * *aSnapshot)
{
nsRefPtr<nsPerformanceSnapshot> snapshot = new nsPerformanceSnapshot();
nsresult rv = snapshot->Init(cx, mProcessId);
nsresult rv = snapshot->Init(cx);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -19,7 +19,6 @@ public:
private:
virtual ~nsPerformanceStatsService();
const uint64_t mProcessId;
protected:
};

View File

@ -147,6 +147,7 @@ function monotinicity_tester(source, testName) {
previous.procesData = snapshot.processData;
// Sanity check on components data.
let set = new Set();
let map = new Map();
for (let item of snapshot.componentsData) {
for (let [probe, k] of [
@ -158,14 +159,25 @@ function monotinicity_tester(source, testName) {
`Sanity check (${testName}): component has a lower ${k} than process`);
}
let key = item.groupId;
SilentAssert.ok(!map.has(key), "The component hasn't been seen yet.");
let key = `{name: ${item.name}, window: ${item.windowId}, addonId: ${item.addonId}, isSystem: ${item.isSystem}}`;
if (set.has(key)) {
// There are at least two components with the same name (e.g. about:blank).
// Don't perform sanity checks on that name until we know how to make
// the difference.
map.delete(key);
continue;
}
map.set(key, item);
set.add(key);
}
for (let [key, item] of map) {
sanityCheck(previous.componentsMap.get(key), item);
previous.componentsMap.set(key, item);
}
info(`Deactivating deduplication check (Bug 1150045)`);
if (false) {
SilentAssert.equal(set.size, snapshot.componentsData.length);
}
});
let interval = window.setInterval(frameCheck, 300);
registerCleanupFunction(() => {