зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1458246 - Use Shmem to pass the profiler data to be able to send large profiler data r=mstange
We were using nsCString to pass the profiler data between processes. But it was failing to send because there is a ~256MB limit for the string data. So we changed it to use Shmem instead. Shmem creates a shared memory and passes the weak reference. With it, we can send larger data without having a problem. MozReview-Commit-ID: 1kj57fZDXVF --HG-- extra : rebase_source : 25a8ab57bcae8012fee1cdd9d4b767036db192d7
This commit is contained in:
Родитель
c3fcb6ab2c
Коммит
1a45365811
|
@ -23,7 +23,7 @@ child:
|
|||
async Pause();
|
||||
async Resume();
|
||||
|
||||
async GatherProfile() returns (nsCString profile);
|
||||
async GatherProfile() returns (Shmem profile);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -88,10 +88,26 @@ CollectProfileOrEmptyString(bool aIsShuttingDown)
|
|||
return profileCString;
|
||||
}
|
||||
|
||||
Shmem
|
||||
ProfilerChild::ConvertProfileStringToShmem(const nsCString& aProfileCString) {
|
||||
Shmem shmem;
|
||||
if (!AllocShmem(aProfileCString.Length(),
|
||||
SharedMemory::TYPE_BASIC,
|
||||
&shmem)) {
|
||||
return shmem;
|
||||
}
|
||||
|
||||
PodCopy(shmem.get<char>(),
|
||||
aProfileCString.BeginReading(),
|
||||
aProfileCString.Length());
|
||||
return shmem;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ProfilerChild::RecvGatherProfile(GatherProfileResolver&& aResolve)
|
||||
{
|
||||
aResolve(CollectProfileOrEmptyString(/* aIsShuttingDown */ false));
|
||||
nsCString profile = CollectProfileOrEmptyString(/* aIsShuttingDown */ false);
|
||||
aResolve(ConvertProfileStringToShmem(profile));
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
|
|
|
@ -618,8 +618,10 @@ nsProfiler::StartGathering(double aSinceTime)
|
|||
RefPtr<nsProfiler> self = this;
|
||||
for (auto profile : profiles) {
|
||||
profile->Then(GetMainThreadSerialEventTarget(), __func__,
|
||||
[self](const nsCString& aResult) {
|
||||
self->GatheredOOPProfile(aResult);
|
||||
[self](const mozilla::ipc::Shmem& aResult) {
|
||||
const nsDependentCString profileString(aResult.get<char>(),
|
||||
aResult.Size<char>());
|
||||
self->GatheredOOPProfile(profileString);
|
||||
},
|
||||
[self](ipc::ResponseRejectReason aReason) {
|
||||
self->GatheredOOPProfile(NS_LITERAL_CSTRING(""));
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace mozilla {
|
|||
// process. The corresponding ProfilerParent actor is created in the main
|
||||
// process, and it will notify us about profiler state changes and request
|
||||
// profiles from us.
|
||||
class ProfilerChild final : public PProfilerChild
|
||||
class ProfilerChild final : public PProfilerChild,
|
||||
public mozilla::ipc::IShmemAllocator
|
||||
{
|
||||
NS_INLINE_DECL_REFCOUNTING(ProfilerChild)
|
||||
|
||||
|
@ -43,6 +44,9 @@ private:
|
|||
mozilla::ipc::IPCResult RecvGatherProfile(GatherProfileResolver&& aResolve) override;
|
||||
|
||||
void ActorDestroy(ActorDestroyReason aActorDestroyReason) override;
|
||||
Shmem ConvertProfileStringToShmem(const nsCString& profile);
|
||||
|
||||
FORWARD_SHMEM_ALLOCATOR_TO(PProfilerChild)
|
||||
|
||||
nsCOMPtr<nsIThread> mThread;
|
||||
bool mDestroyed;
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
static mozilla::ipc::Endpoint<PProfilerChild> CreateForProcess(base::ProcessId aOtherPid);
|
||||
|
||||
typedef MozPromise<nsCString, ResponseRejectReason, false> SingleProcessProfilePromise;
|
||||
typedef MozPromise<Shmem, ResponseRejectReason, true> SingleProcessProfilePromise;
|
||||
|
||||
// The following static methods can be called on any thread, but they are
|
||||
// no-ops on anything other than the main thread.
|
||||
|
|
Загрузка…
Ссылка в новой задаче