Skip to content

Commit

Permalink
-Heavily improved editor startup and exit performance
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Jun 8, 2016
1 parent 193272a commit d61b91c
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 191 deletions.
181 changes: 93 additions & 88 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1377,120 +1377,125 @@ void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
while(!ea->quit_request) {

String adb=EditorSettings::get_singleton()->get("android/adb");
if (!FileAccess::exists(adb)) {
OS::get_singleton()->delay_usec(3000000);
continue; //adb not configured
}

String devices;
List<String> args;
args.push_back("devices");
int ec;
Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec);
Vector<String> ds = devices.split("\n");
Vector<String> ldevices;
for(int i=1;i<ds.size();i++) {

String d = ds[i];
int dpos = d.find("device");
if (dpos==-1)
continue;
d=d.substr(0,dpos).strip_edges();
// print_line("found devuce: "+d);
ldevices.push_back(d);
}
if (FileAccess::exists(adb)) {

String devices;
List<String> args;
args.push_back("devices");
int ec;
Error err = OS::get_singleton()->execute(adb,args,true,NULL,&devices,&ec);
Vector<String> ds = devices.split("\n");
Vector<String> ldevices;
for(int i=1;i<ds.size();i++) {

String d = ds[i];
int dpos = d.find("device");
if (dpos==-1)
continue;
d=d.substr(0,dpos).strip_edges();
// print_line("found devuce: "+d);
ldevices.push_back(d);
}

ea->device_lock->lock();
ea->device_lock->lock();

bool different=false;
bool different=false;

if (devices.size()!=ldevices.size()) {
if (devices.size()!=ldevices.size()) {

different=true;
} else {
different=true;
} else {

for(int i=0;i<ea->devices.size();i++) {
for(int i=0;i<ea->devices.size();i++) {

if (ea->devices[i].id!=ldevices[i]) {
different=true;
break;
if (ea->devices[i].id!=ldevices[i]) {
different=true;
break;
}
}
}
}

if (different) {
if (different) {


Vector<Device> ndevices;
Vector<Device> ndevices;

for(int i=0;i<ldevices.size();i++) {
for(int i=0;i<ldevices.size();i++) {

Device d;
d.id=ldevices[i];
for(int j=0;j<ea->devices.size();j++) {
if (ea->devices[j].id==ldevices[i]) {
d.description=ea->devices[j].description;
d.name=ea->devices[j].name;
Device d;
d.id=ldevices[i];
for(int j=0;j<ea->devices.size();j++) {
if (ea->devices[j].id==ldevices[i]) {
d.description=ea->devices[j].description;
d.name=ea->devices[j].name;
}
}
}

if (d.description=="") {
//in the oven, request!
args.clear();
args.push_back("-s");
args.push_back(d.id);
args.push_back("shell");
args.push_back("cat");
args.push_back("/system/build.prop");
int ec;
String dp;

Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec);
print_line("RV: "+itos(ec));
Vector<String> props = dp.split("\n");
String vendor;
String device;
d.description+"Device ID: "+d.id+"\n";
for(int j=0;j<props.size();j++) {

String p = props[j];
if (p.begins_with("ro.product.model=")) {
device=p.get_slice("=",1).strip_edges();
} else if (p.begins_with("ro.product.brand=")) {
vendor=p.get_slice("=",1).strip_edges().capitalize();
} else if (p.begins_with("ro.build.display.id=")) {
d.description+="Build: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.build.version.release=")) {
d.description+="Release: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.product.cpu.abi=")) {
d.description+="CPU: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.product.manufacturer=")) {
d.description+="Manufacturer: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.board.platform=")) {
d.description+="Chipset: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.opengles.version=")) {
uint32_t opengl = p.get_slice("=",1).to_int();
d.description+="OpenGL: "+itos(opengl>>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n";
if (d.description=="") {
//in the oven, request!
args.clear();
args.push_back("-s");
args.push_back(d.id);
args.push_back("shell");
args.push_back("cat");
args.push_back("/system/build.prop");
int ec;
String dp;

Error err = OS::get_singleton()->execute(adb,args,true,NULL,&dp,&ec);
print_line("RV: "+itos(ec));
Vector<String> props = dp.split("\n");
String vendor;
String device;
d.description+"Device ID: "+d.id+"\n";
for(int j=0;j<props.size();j++) {

String p = props[j];
if (p.begins_with("ro.product.model=")) {
device=p.get_slice("=",1).strip_edges();
} else if (p.begins_with("ro.product.brand=")) {
vendor=p.get_slice("=",1).strip_edges().capitalize();
} else if (p.begins_with("ro.build.display.id=")) {
d.description+="Build: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.build.version.release=")) {
d.description+="Release: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.product.cpu.abi=")) {
d.description+="CPU: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.product.manufacturer=")) {
d.description+="Manufacturer: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.board.platform=")) {
d.description+="Chipset: "+p.get_slice("=",1).strip_edges()+"\n";
} else if (p.begins_with("ro.opengles.version=")) {
uint32_t opengl = p.get_slice("=",1).to_int();
d.description+="OpenGL: "+itos(opengl>>16)+"."+itos((opengl>>8)&0xFF)+"."+itos((opengl)&0xFF)+"\n";
}
}

d.name=vendor+" "+device;
// print_line("name: "+d.name);
// print_line("description: "+d.description);

}

d.name=vendor+" "+device;
// print_line("name: "+d.name);
// print_line("description: "+d.description);
ndevices.push_back(d);

}

ndevices.push_back(d);

ea->devices=ndevices;
ea->devices_changed=true;
}

ea->devices=ndevices;
ea->devices_changed=true;
ea->device_lock->unlock();
}

ea->device_lock->unlock();
uint64_t wait = 3000000;
uint64_t time = OS::get_singleton()->get_ticks_usec();
while(OS::get_singleton()->get_ticks_usec() - time < wait ) {
OS::get_singleton()->delay_usec(1000);
if (ea->quit_request)
break;
}

OS::get_singleton()->delay_usec(3000000);
}

if (EditorSettings::get_singleton()->get("android/shutdown_adb_on_exit")) {
Expand Down
122 changes: 63 additions & 59 deletions platform/bb10/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,95 +532,99 @@ void EditorExportPlatformBB10::_device_poll_thread(void *ud) {
if (windows)
bb_deploy+=".bat";

if (!FileAccess::exists(bb_deploy)) {
OS::get_singleton()->delay_usec(3000000);
continue; //adb not configured
}
if (FileAccess::exists(bb_deploy)) {

Vector<Device> devices;
Vector<Device> devices;


for (int i=0;i<MAX_DEVICES;i++) {
for (int i=0;i<MAX_DEVICES;i++) {

String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/host");
if (host==String())
continue;
String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password");
if (pass==String())
continue;
String host = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/host");
if (host==String())
continue;
String pass = EditorSettings::get_singleton()->get("blackberry/device_"+itos(i+1)+"/password");
if (pass==String())
continue;

List<String> args;
args.push_back("-listDeviceInfo");
args.push_back(host);
args.push_back("-password");
args.push_back(pass);
List<String> args;
args.push_back("-listDeviceInfo");
args.push_back(host);
args.push_back("-password");
args.push_back(pass);


int ec;
String dp;
int ec;
String dp;

Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec);
Error err = OS::get_singleton()->execute(bb_deploy,args,true,NULL,&dp,&ec);

if (err==OK && ec==0) {
if (err==OK && ec==0) {

Device dev;
dev.index=i;
String descr;
Vector<String> ls=dp.split("\n");
Device dev;
dev.index=i;
String descr;
Vector<String> ls=dp.split("\n");

for(int i=0;i<ls.size();i++) {
for(int i=0;i<ls.size();i++) {

String l = ls[i].strip_edges();
if (l.begins_with("modelfullname::")) {
dev.name=l.get_slice("::",1);
descr+="Model: "+dev.name+"\n";
}
if (l.begins_with("modelnumber::")) {
String s = l.get_slice("::",1);
dev.name+=" ("+s+")";
descr+="Model Number: "+s+"\n";
}
if (l.begins_with("scmbundle::"))
descr+="OS Version: "+l.get_slice("::",1)+"\n";
if (l.begins_with("[n]debug_token_expiration::"))
descr+="Debug Token Expires:: "+l.get_slice("::",1)+"\n";

String l = ls[i].strip_edges();
if (l.begins_with("modelfullname::")) {
dev.name=l.get_slice("::",1);
descr+="Model: "+dev.name+"\n";
}
if (l.begins_with("modelnumber::")) {
String s = l.get_slice("::",1);
dev.name+=" ("+s+")";
descr+="Model Number: "+s+"\n";
}
if (l.begins_with("scmbundle::"))
descr+="OS Version: "+l.get_slice("::",1)+"\n";
if (l.begins_with("[n]debug_token_expiration::"))
descr+="Debug Token Expires:: "+l.get_slice("::",1)+"\n";

dev.description=descr;
devices.push_back(dev);
}

dev.description=descr;
devices.push_back(dev);
}

}

bool changed=false;
bool changed=false;


ea->device_lock->lock();
ea->device_lock->lock();

if (ea->devices.size()!=devices.size()) {
changed=true;
} else {
if (ea->devices.size()!=devices.size()) {
changed=true;
} else {

for(int i=0;i<ea->devices.size();i++) {
for(int i=0;i<ea->devices.size();i++) {

if (ea->devices[i].index!=devices[i].index) {
changed=true;
break;
if (ea->devices[i].index!=devices[i].index) {
changed=true;
break;
}
}
}
}

if (changed) {
if (changed) {

ea->devices=devices;
ea->devices_changed=true;
}
ea->devices=devices;
ea->devices_changed=true;
}

ea->device_lock->unlock();
ea->device_lock->unlock();
}

OS::get_singleton()->delay_usec(3000000);

uint64_t wait = 3000000;
uint64_t time = OS::get_singleton()->get_ticks_usec();
while(OS::get_singleton()->get_ticks_usec() - time < wait ) {
OS::get_singleton()->delay_usec(1000);
if (ea->quit_request)
break;
}
}

}
Expand Down
Loading

1 comment on commit d61b91c

@akien-mga
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woot, that's a great improvement!

The closing time went from 4-5 s to 1-2 s here on X11 (comparing 2.0.3 to the current master branch, but I don't think the performance had changed much in between).

For the loading time I don't see a big change yet, but I only tested briefly.

One potential new issue in the terminal on closing:

settings changed
ERROR: ~List: Condition ' _first!=__null ' is true.
   At: core/self_list.h:82.
ERROR: ~List: Condition ' _first!=__null ' is true.
   At: core/self_list.h:82.

Please sign in to comment.