Skip to content

Commit

Permalink
wsd: dump the smaps summary on USR1
Browse files Browse the repository at this point in the history
To get memory statistics, we dump smaps_rollup
in dumpState, which is invoked on SIGUSR1.

Change-Id: Ic38aa4f265a2b9ccb06eb6c4b6ba3d10b7dc6b7a
Signed-off-by: Ashod Nakashian <[email protected]>
  • Loading branch information
Ashod committed Oct 6, 2024
1 parent 2b2d1bb commit 0a35011
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
18 changes: 12 additions & 6 deletions kit/Kit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2494,8 +2494,14 @@ void Document::dumpState(std::ostream& oss)
<< "\n\tduringLoad: " << _duringLoad
<< "\n\tmodified: " << name(_modified)
<< "\n\tbgSaveProc: " << _isBgSaveProcess
<< "\n\tbgSaveDisabled: "<< _isBgSaveDisabled
<< "\n";
<< "\n\tbgSaveDisabled: "<< _isBgSaveDisabled;

std::string smap;
if (const ssize_t size = FileUtil::readFile("/proc/self/smaps_rollup", smap); size <= 0)
oss << "\n smaps_rollup: <unavilable>";
else
oss << "\n smaps_rollup: " << smap;
oss << '\n';

// dumpState:
// TODO: _websocketHandler - but this is an odd one.
Expand All @@ -2507,7 +2513,7 @@ void Document::dumpState(std::ostream& oss)
<< " editorId: " << it.second->getDoc()->getEditorId()
<< " mobileAppDocId: " << it.second->getDoc()->getMobileAppDocId();
}
oss << "\n";
oss << '\n';

_deltaPool.dumpState(oss);
_sessions.dumpState(oss);
Expand All @@ -2522,7 +2528,7 @@ void Document::dumpState(std::ostream& oss)
oss << "\n\t\tviewId: " << it.first
<< " last update time(ms): " << ms;
}
oss << "\n";
oss << '\n';

oss << "\tspeedCount:";
for (const auto &it : _speedCount)
Expand All @@ -2543,14 +2549,14 @@ void Document::dumpState(std::ostream& oss)
<< " readOnly: " << it.second.isReadOnly()
<< " connected: " << it.second.isConnected();
}
oss << "\n";
oss << '\n';

char *pState = nullptr;
_loKit->dumpState("", &pState);
oss << "lok state:\n";
if (pState)
oss << pState;
oss << "\n";
oss << '\n';
}

#if !defined BUILDING_TESTS && !MOBILEAPP && !LIBFUZZER
Expand Down
6 changes: 6 additions & 0 deletions wsd/COOLWSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4104,6 +4104,12 @@ class COOLWSDServer
<< "\n UserInterface: " << COOLWSD::UserInterface
;

std::string smap;
if (const ssize_t size = FileUtil::readFile("/proc/self/smaps_rollup", smap); size <= 0)
os << "\n smaps_rollup: <unavilable>";
else
os << "\n smaps_rollup: " << smap;

#if !MOBILEAPP
if (FetchHttpSession)
{
Expand Down

0 comments on commit 0a35011

Please sign in to comment.