Skip to content

Commit

Permalink
Make session monitor communication async
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardofandrade committed May 8, 2020
1 parent 0f9ff50 commit a3b4d4f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@
* Fixed failure to open files after an attempt to open a very large file (#6637)
* Fixed Data Viewer getting out of sync with the underlying data when changing live viewer object (#1819)
* Fixed issue where attempts to plot could fail if R tempdir was deleted (#2214)
* Fixed issue that caused sessions to freeze due to slow I/O for monitor logs (Pro #1259)
20 changes: 18 additions & 2 deletions src/cpp/session/SessionMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1662,17 +1662,33 @@ bool ensureUtf8Charset()
#endif
}

// io_service for performing monitor work on the thread
boost::asio::io_service s_ioService;

void monitorWorkerThreadFunc()
{
boost::asio::io_service::work work(s_ioService);
s_ioService.run();
}

void initMonitorClient()
{
if (!options().getBoolOverlayOption(kLauncherSessionOption))
{
monitor::initializeMonitorClient(core::system::getenv(kMonitorSocketPathEnvVar),
options().monitorSharedSecret());
options().monitorSharedSecret(),
s_ioService);
}
else
{
modules::overlay::initMonitorClient();
modules::overlay::initMonitorClient(s_ioService);
}

// start the monitor work thread
// we handle monitor calls in a separate thread to ensure that calls
// to the monitor (which are likely across machines and thus very expensive)
// do not hamper the liveliness of the session as a whole
core::thread::safeLaunchThread(monitorWorkerThreadFunc);
}

} // anonymous namespace
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/session/modules/overlay/SessionOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int verifyInstallation()
return EXIT_SUCCESS;
}

void initMonitorClient()
void initMonitorClient(boost::asio::io_service& ioService)
{
}

Expand Down
3 changes: 2 additions & 1 deletion src/cpp/session/modules/overlay/SessionOverlay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define SESSION_OVERLAY_HPP

#include <string>
#include <boost/asio/io_service.hpp>

namespace rstudio {
namespace core {
Expand All @@ -38,7 +39,7 @@ void streamLauncherOutput(const std::string& jobId,

int verifyInstallation();

void initMonitorClient();
void initMonitorClient(boost::asio::io_service& ioService);

core::Error initialize();

Expand Down

0 comments on commit a3b4d4f

Please sign in to comment.