urllib2 has big perf hit!
#1
Hi All,
I noticed an ATV2 issue yesterday on that causes a 4 sec directory load time on ATV2 vs a 2 sec load on ipad 1 : http://forum.xbmc.org/showthread.php?tid=106453.

The perferance issue seems to stem ATV2 pythons interpeter on common python libraries eg: urllib2 import call add 2 sec to page load time.

Should we code around it or is there are plans to optimise this library?

Thanks,
slyi

PHP Code:
import xbmcgui
import xbmcplugin

#uncomment urllib2 import and see 2 sec increase in load time
#import urllib2 

def showRoot(localpathhandle):    
    
li=xbmcgui.ListItem('See perf difference with urllib2')
    
u=localpath
    xbmcplugin
.addDirectoryItem(handle,u,li,True)
    
xbmcplugin.endOfDirectory(handle)
    
def main():
    
showRoot(sys.argv[0],int(sys.argv[1]))
    
if 
__name__ == "__main__":
    
main() 
Reply
#2
Is this something that is been worked on? Or is a limitation of the atv2 that you have to live with?

I found it annoying, ever since I noticed it, when I'm used of it being so fast.
Reply
#3
OK, I did some playing around on the ipad and it's httplib.py that causing the slow down. httplib.py is imported from urllib2. Will have a look at the atv2 in a few days.
Reply
#4
It seems to be httplib alright, but cant manage to get the root delay.

BTW: If i create a raw http get using a socket, there is no delay so it not the underlaying network connection.

PHP Code:
import socket    
HOST 
'www.google.com'
PORT 80
sock 
socket.socket(socket.AF_INETsocket.SOCK_STREAM)
sock.connect((HOSTPORT))
sock.sendall("GET /pda HTTP/1.0\r\n\r\n")
data ''
rcvChunk sock.recv(1024)
while 
1:
    
data datarcvChunk
    rcvChunk 
sock.recv(1024)
    if 
rcvChunk == '':
        break

print 
str(data)    
sock.close() 
Reply
#5
OK, I solved the slowness issue.
You need to chmod 777 on /private/var/null/Applications/XBMC.frappliance/Frameworks/lib/python2.6/

The compile files (*.pyc) weren't been created, so when you change the permissions, they get created and the addons work quicker. Not instant but definitely quicker.

Bug logged http://trac.xbmc.org/ticket/12079
Reply
#6
Great catch. Wow thats so much faster, same speed now as my windows machine for directory loading. These pyc files need to be part of the install package or the install script should chmod the folder.

PHP Code:
find / -name python2.6 -print | xargs chmod -R 777 

I had thought we had live with this issue forever!
Reply
#7
nice catch, I bet if XBMC.frapp and down was set chown mobile:mobile, that would work too.
Reply
#8
davilla Wrote:nice catch, I bet if XBMC.frapp and down was set chown mobile:mobile, that would work too.

I bet your right, and more secure too. Hopefully you will be able to add it to the next nightly, if you get the chance. I'd say 95% of people won't notice, but it's something that really bothered me, coming from a ATV1 user.

How come there are two python2.6 directories? /Applications/XBMC.frappliance/Frameworks/lib/python2.6/ and /private/var/null/Applications/XBMC.frappliance/Frameworks/lib/python2.6/
Reply
#9
Well done guys! Especially welcome news on this platform.
Macmini Server 2011 i7 Quad Core, OS 10.8.2, Amp Onkyo TX-SR308 USB WD drives 3x2TB TV Samsung Plasma 720p EyeTV Integration
There are only 10 kinds of people in this world, those who understand binary, and those who don't.



Reply
#10
rogerthis Wrote:I bet your right, and more secure too. Hopefully you will be able to add it to the next nightly, if you get the chance. I'd say 95% of people won't notice, but it's something that really bothered me, coming from a ATV1 user.

How come there are two python2.6 directories? /Applications/XBMC.frappliance/Frameworks/lib/python2.6/ and /private/var/null/Applications/XBMC.frappliance/Frameworks/lib/python2.6/

One is an alias to the other.
Reply
#11
Fast fix by davilla on https://github.com/xbmc/xbmc/commit/83a1...4af47c3a63
Reply
#12
slyi Wrote:Fast fix by davilla on https://github.com/xbmc/xbmc/commit/83a1...4af47c3a63

+1 Thanks
Reply
#13
Sweet
Reply
#14
+1e6 for rogerthis dogging it down Smile
Reply
#15
Guys, can I just add that the implementation of this has made a significant difference. As someone remarked, browsing is comparable to some of the other more powerful platforms. I took a long shot and tried some of the heavier skins as an experiment without luck but... thanks again.
Macmini Server 2011 i7 Quad Core, OS 10.8.2, Amp Onkyo TX-SR308 USB WD drives 3x2TB TV Samsung Plasma 720p EyeTV Integration
There are only 10 kinds of people in this world, those who understand binary, and those who don't.



Reply

Logout Mark Read Team Forum Stats Members Help
urllib2 has big perf hit!0