Skip to content

Commit 04f8b0e

Browse files
committed
Added drop_caches.sh script.
Added -np (-noPython) flag for faster startups. Made UI more responsive while loading large files.
1 parent 15bc78d commit 04f8b0e

File tree

3 files changed

+95
-74
lines changed

3 files changed

+95
-74
lines changed

bin/helpers/drop_caches.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Flushes the disk caches to measure performance of vmrv2 on a cold start.
5+
#
6+
7+
# Write any dirty pages to disk
8+
sync
9+
10+
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'

src/docs/HISTORY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ v1.4.1
6565
- Voice Annotations are now saved and played in stereo.
6666
- Added blinking recording button for Voice Annotation.
6767
- Fixed incorrect resizing of window when being in fullscreen and loading a
68-
smaller clip than the window one.
68+
smaller clip than the window one.
69+
- Added a -np (-noPython) flag for faster start ups.
6970

7071
v1.4.0
7172
======

src/lib/mrvApp/mrvApp.cpp

Lines changed: 83 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ namespace mrv
148148
std::string audioFileName;
149149
std::string compareFileName;
150150
#ifdef MRV2_PYBIND11
151+
bool noPython = false;
151152
std::string pythonScript;
152153
std::string pythonArgs;
153154
#endif
@@ -407,6 +408,9 @@ namespace mrv
407408
string::Format("{0}").arg(p.options.lutOptions.order),
408409
string::join(timeline::getLUTOrderLabels(), ", ")),
409410
#ifdef MRV2_PYBIND11
411+
app::CmdLineFlagOption::create(
412+
p.options.noPython, {"-noPython", "-np"},
413+
_("Don't load python for faster startup.")),
410414
app::CmdLineValueOption<std::string>::create(
411415
p.options.pythonScript, {"-pythonScript", "-ps"},
412416
_("Python Script to run and exit.")),
@@ -1092,85 +1096,85 @@ namespace mrv
10921096
}
10931097

10941098
#ifdef MRV2_PYBIND11
1095-
DBG;
1096-
// Import the mrv2 python module so we read all python
1097-
// plug-ins.
1098-
py::module::import("mrv2");
1099-
DBG;
1099+
if (!p.options.noPython)
1100+
{
1101+
// Import the mrv2 python module so we read all python
1102+
// plug-ins.
1103+
py::module::import("mrv2");
11001104

1101-
// Discover Python plugins
1102-
mrv2_discover_python_plugins();
1103-
DBG;
1105+
// Discover Python plugins
1106+
mrv2_discover_python_plugins();
11041107

1105-
//
1106-
// Run command-line python script.
1107-
//
1108-
if (!p.options.pythonScript.empty())
1109-
{
1110-
std::string script = p.options.pythonScript;
1111-
if (!file::isReadable(script))
1108+
//
1109+
// Run command-line python script.
1110+
//
1111+
if (!p.options.pythonScript.empty())
11121112
{
1113-
// Search for script in $STUDIOPATH/python/ directory
1114-
std::string studio_script = studiopath() + "/python/" + script;
1115-
if (file::isReadable(studio_script))
1116-
{
1117-
script = studio_script;
1118-
}
1119-
else
1113+
std::string script = p.options.pythonScript;
1114+
if (!file::isReadable(script))
11201115
{
1121-
// Search for script in mrv2's python demos directory.
1122-
script = pythonpath() + script;
1123-
if (!file::isReadable(script))
1116+
// Search for script in $STUDIOPATH/python/ directory
1117+
std::string studio_script = studiopath() + "/python/" + script;
1118+
if (file::isReadable(studio_script))
11241119
{
1125-
std::cerr
1126-
<< std::string(
1127-
string::Format(
1128-
_("Could not read python script '{0}'"))
1129-
.arg(p.options.pythonScript))
1130-
<< std::endl;
1131-
_exit = 1;
1132-
return;
1120+
script = studio_script;
1121+
}
1122+
else
1123+
{
1124+
// Search for script in mrv2's python demos directory.
1125+
script = pythonpath() + script;
1126+
if (!file::isReadable(script))
1127+
{
1128+
std::cerr
1129+
<< std::string(
1130+
string::Format(
1131+
_("Could not read python script '{0}'"))
1132+
.arg(p.options.pythonScript))
1133+
<< std::endl;
1134+
_exit = 1;
1135+
return;
1136+
}
11331137
}
11341138
}
1135-
}
11361139

1137-
p.pythonArgs = std::make_unique<PythonArgs>(p.options.pythonArgs);
1140+
p.pythonArgs = std::make_unique<PythonArgs>(p.options.pythonArgs);
11381141

1139-
LOG_STATUS(std::string(
1140-
string::Format(_("Running python script '{0}'")).arg(script)));
1141-
const auto& args = p.pythonArgs->getArguments();
1142+
LOG_STATUS(std::string(
1143+
string::Format(_("Running python script '{0}'")).arg(script)));
1144+
const auto& args = p.pythonArgs->getArguments();
11421145

1143-
if (!args.empty())
1144-
{
1145-
LOG_STATUS(_("with Arguments:"));
1146-
std::string out = "[";
1147-
out += tl::string::join(args, ',');
1148-
out += "]";
1149-
LOG_STATUS(out);
1150-
}
1146+
if (!args.empty())
1147+
{
1148+
LOG_STATUS(_("with Arguments:"));
1149+
std::string out = "[";
1150+
out += tl::string::join(args, ',');
1151+
out += "]";
1152+
LOG_STATUS(out);
1153+
}
11511154

1152-
std::ifstream is(script);
1153-
std::stringstream s;
1154-
s << is.rdbuf();
1155-
try
1156-
{
1157-
py::exec(s.str());
1158-
}
1159-
catch (const std::exception& e)
1160-
{
1161-
std::cerr << _("Python Error: ") << std::endl
1162-
<< e.what() << std::endl;
1163-
_exit = 1;
1155+
std::ifstream is(script);
1156+
std::stringstream s;
1157+
s << is.rdbuf();
1158+
try
1159+
{
1160+
py::exec(s.str());
1161+
}
1162+
catch (const std::exception& e)
1163+
{
1164+
std::cerr << _("Python Error: ") << std::endl
1165+
<< e.what() << std::endl;
1166+
_exit = 1;
1167+
return;
1168+
}
1169+
delete ui;
1170+
ui = nullptr;
11641171
return;
11651172
}
1166-
delete ui;
1167-
ui = nullptr;
1168-
return;
1169-
}
11701173

1171-
DBG;
1172-
// Redirect Python's stdout/stderr to my own class
1173-
p.pythonStdErrOutRedirect.reset(new PyStdErrOutStreamRedirect);
1174+
DBG;
1175+
// Redirect Python's stdout/stderr to my own class
1176+
p.pythonStdErrOutRedirect.reset(new PyStdErrOutStreamRedirect);
1177+
}
11741178
#endif
11751179

11761180
// Open Panel Windows if not loading a session file.
@@ -1330,6 +1334,7 @@ namespace mrv
13301334
void App::startPlayback()
13311335
{
13321336
TLRENDER_P();
1337+
13331338

13341339
p.player->setPlayback(timeline::Playback::Stop);
13351340

@@ -1366,6 +1371,9 @@ namespace mrv
13661371
endTime = endTime.floor();
13671372
startTime = startTime.ceil();
13681373

1374+
// Keep UI responsive
1375+
Fl::check();
1376+
13691377
for (const auto& t : value.videoFrames)
13701378
{
13711379
if (t.start_time() <= startTime &&
@@ -1424,6 +1432,9 @@ namespace mrv
14241432
endTime = endTime.floor();
14251433
startTime = startTime.ceil();
14261434

1435+
// Keep UI responsive
1436+
Fl::check();
1437+
14271438
for (const auto& t : value.videoFrames)
14281439
{
14291440
if (t.start_time() <= startTime &&
@@ -1460,12 +1471,13 @@ namespace mrv
14601471
// make sure to show all frames
14611472
if (p.options.playback == timeline::Playback::Count)
14621473
p.options.playback = timeline::Playback::Forward;
1463-
1474+
14641475
Fl::add_timeout(
14651476
0.0, (Fl_Timeout_Handler)start_playback_cb, this);
14661477
}
14671478
}
14681479
p.running = true;
1480+
14691481
return Fl::run();
14701482
}
14711483

@@ -1941,7 +1953,8 @@ namespace mrv
19411953
if (file::isUSD(item->path))
19421954
{
19431955
#ifdef MRV2_PYBIND11
1944-
py::gil_scoped_release release;
1956+
if (!p.options.noPython)
1957+
py::gil_scoped_release release;
19451958
#endif
19461959
otioTimeline = item->audioPath.isEmpty()
19471960
? timeline::create(
@@ -2054,7 +2067,7 @@ namespace mrv
20542067
{
20552068
player->setPlayback(
20562069
timeline::Playback::Forward);
2057-
2070+
20582071
// If we have autoplayback on and auto hide
20592072
// pixel bar, do so here.
20602073
const int autoHide =
@@ -2216,13 +2229,10 @@ namespace mrv
22162229
}
22172230
}
22182231

2219-
DBG;
22202232
cacheUpdate();
2221-
2222-
DBG;
2233+
22232234
_audioUpdate();
2224-
2225-
DBG;
2235+
22262236
}
22272237

22282238
otime::RationalTime App::_cacheReadAhead() const

0 commit comments

Comments
 (0)