Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve auto-updater experience #7842

Merged
merged 2 commits into from Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions rpcs3/main.cpp
Expand Up @@ -60,6 +60,8 @@ static atomic_t<char*> s_argv0;
extern char **environ;
#endif

LOG_CHANNEL(sys_log, "SYS");

[[noreturn]] extern void report_fatal_error(const std::string& text)
{
const bool local = s_qt_init.try_lock();
Expand Down Expand Up @@ -170,6 +172,7 @@ const char* arg_styles = "styles";
const char* arg_style = "style";
const char* arg_stylesheet = "stylesheet";
const char* arg_error = "error";
const char* arg_updating = "updating";

int find_arg(std::string arg, int& argc, char* argv[])
{
Expand Down Expand Up @@ -263,6 +266,15 @@ QCoreApplication* createApplication(int& argc, char* argv[])

int main(int argc, char** argv)
{
#ifdef _WIN32
ULONG64 intro_cycles{};
QueryThreadCycleTime(GetCurrentThread(), &intro_cycles);
#elif defined(RUSAGE_THREAD)
struct ::rusage intro_stats{};
::getrusage(RUSAGE_THREAD, &intro_stats);
const u64 intro_time = (intro_stats.ru_utime.tv_sec + intro_stats.ru_stime.tv_sec) * 1000000000ull + (intro_stats.ru_utime.tv_usec + intro_stats.ru_stime.tv_usec) * 1000ull;
#endif

s_argv0 = argv[0]; // Save for report_fatal_error

// Only run RPCS3 to display an error
Expand All @@ -284,9 +296,13 @@ int main(int argc, char** argv)

fs::file instance_lock;

for (u32 num = 0; num < 100 && !instance_lock.open(lock_name, fs::rewrite + fs::lock); num++)
// True if an argument --updating found
const bool is_updating = find_arg(arg_updating, argc, argv) != 0;

// Keep trying to lock the file for ~2s normally, and for ~10s in the case of --updating
for (u32 num = 0; num < (is_updating ? 500u : 100u) && !instance_lock.open(lock_name, fs::rewrite + fs::lock); num++)
{
std::this_thread::sleep_for(30ms);
std::this_thread::sleep_for(20ms);
}

if (!instance_lock)
Expand Down Expand Up @@ -354,6 +370,12 @@ int main(int argc, char** argv)
logs::set_init({std::move(ver), std::move(os)});
}

#ifdef _WIN32
sys_log.notice("Initialization times before main(): %fGc", intro_cycles / 1000000000.);
#elif defined(RUSAGE_THREAD)
sys_log.notice("Initialization times before main(): %fs", intro_time / 1000000000.);
#endif

#ifdef __linux__
struct ::rlimit rlim;
rlim.rlim_cur = 4096;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/rpcs3qt/update_manager.cpp
Expand Up @@ -596,9 +596,9 @@ bool update_manager::handle_rpcs3()
QMessageBox::information(m_parent, tr("Auto-updater"), tr("Update successful!"));

#ifdef _WIN32
const int ret = _wexecl(orig_path, orig_path, nullptr);
const int ret = _wexecl(orig_path, orig_path, L"--updating", nullptr);
#else
const int ret = execl(replace_path.c_str(), replace_path.c_str(), nullptr);
const int ret = execl(replace_path.c_str(), replace_path.c_str(), "--updating", nullptr);
#endif
if (ret == -1)
{
Expand Down