Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat Nov 07, 2009 8:35 pm 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
I have enabled X11 forwarding in my SSHD config and am tunneling my connection using PuTTY along with Xming to display. When I run xv <test.jpg> there is a huge initial delay.

I don't think it is just the regular "encrypted tunneled connections are slow" thing because what happens is that there is a > 1 minute delay before the window appears. Once the window is open, I see the image get painted slowly (around 8 sec) but that is "believably slow" as opposed to this huge delay before the window even appears.

The JPG file is only ~50k.

Approximately the same behavior occurs with the display command from ImageMagick too. (Although it doesn't paint incrementally)

If I run xclock, it takes about 1 second for the window to appear.

Any ideas?


Top
   
 Post subject:
PostPosted: Sat Nov 07, 2009 11:57 pm 
Offline
Senior Newbie

Joined: Sat Nov 07, 2009 4:20 pm
Posts: 7
Atomicdog,

Have a look at my post and tell me if you think they are a little similar? My problem is that SSH terminal basically freezes up when browser data is forwarded through it.

If I wait long enough and don't use the browser (socks mode), then the SSH term goes back to normal and accepts input again.

http://www.linode.com/forums/viewtopic.php?t=4806


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 1:38 am 
Offline
Senior Newbie

Joined: Sat Nov 07, 2009 4:20 pm
Posts: 7
Is your SSHD port set to one above 1024? Try one below if so... see if it makes a difference.


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 1:49 am 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
Yeah, I saw your post out there, but I don't think it's the same because yours always works fine at first and mine always has a delay initially. Yours seems more intermittent.

SSHD is running on the standard port. Unfortunately, I can't even narrow this down as to whether it is something that needs to be changed on the SSHD side or the XMing side yet... :?


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 4:44 am 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
Here is some useful information from an ltrace of xv:

Code:
% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
 47.68  152.597617      198694       768 XGetImage
 39.68  126.984018      165343       768 XAllocColor
  3.74   11.980527      630554        19 XNextEvent
  2.58    8.256200      550413        15 XSync
  2.54    8.139029     4069514         2 XPutImage
  ...


Investigating why this is so slow...


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 5:47 am 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
Tried removing xcb, per https://bugs.launchpad.net/ubuntu/+bug/241063

Code:
$ ldd `which xv`
    linux-gate.so.1 =>  (0xb7fae000)
    libz.so.1 => /lib/libz.so.1 (0xb7f94000)
    libX11.so.6 => /usr/lib/libX11.so.6 (0xb7e73000)
    libm.so.6 => /lib/libm.so.6 (0xb7e4c000)
    libjpeg.so.7 => /usr/lib/libjpeg.so.7 (0xb7e15000)
    libpng12.so.0 => /usr/lib/libpng12.so.0 (0xb7df0000)
    libtiff.so.3 => /usr/lib/libtiff.so.3 (0xb7d9a000)
    libc.so.6 => /lib/libc.so.6 (0xb7c2e000)
    libXau.so.6 => /usr/lib/libXau.so.6 (0xb7c2a000)
    libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb7c24000)
    libdl.so.2 => /lib/libdl.so.2 (0xb7c1f000)
    /lib/ld-linux.so.2 (0xb7faf000)


This did not fix the issue.


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 6:00 am 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
Sniffing the network shows that during the long delay period, I am getting lots of very small packets sent back and forth across the tunnel.

The following is an example of log messages that occur for the majority of the wait time.

Code:
<Linode> --> <Client>   SSH   Encrypted response packet len=68
<Client> --> <Linode>   SSH   Encrypted request packet len=84
<Linode> --> <Client>   SSH   Encrypted response packet len=100
<Client> --> <Linode>   SSH   Encrypted request packet len=84


Top
   
PostPosted: Sun Nov 08, 2009 12:22 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
AtomicDog wrote:
I have enabled X11 forwarding in my SSHD config and am tunneling my connection using PuTTY along with Xming to display. When I run xv <test.jpg> there is a huge initial delay.

...

If I run xclock, it takes about 1 second for the window to appear.

Any ideas?

The X protocol has been described as the worst remote display solution, except for every other one. It's not so much that it works badly, but everything else works worse.

If you're X tunnelling then your remote X application is talking to your local X server (your desktop). Starting up an application can involve a _lot_ of small requests from the application to the server (your desktop), and a lot of communication back from the server to the application. If your home upload speed is slow or saturated then this can cause massively long application startup delays, depending on the number of widgets in the application, and so on.

In 1995 I attempted to run Netscape - I forget which ancient version - remotely; my local machine was a Sparc IPC and the machine running netscape was a Sparc 4. The connection... a 28.8K PPP modem dialup. It took over 10 minutes for the application to start (a lot of resources got thrown over the modem link; it was 100% busy), but once it had started then it was actually quite usable. I think you may be seeing similar.

X is a great protocol in that remote programs are considered equivalent in terms of desktop access; whether a program runs on your local machine, a LAN away, a WAN away, over the internet... they all interact similarly to the X server and are equal. This si why all other remote desktop solutions are worse. Unfortunately the result can be painfully slow startup times and network intensive communication; this is why X is the worst.

(Ok, that hasn't helped you....)

You might want to look into an X protocol analyser (google for one); this can tell you what X calls the application is making and might give you an idea of the problem. You might also want to consider a different remote display technology where a remote desktop is displayed as blocks (eg VNC). It's not as well integrated into your desktop, but may be faster.

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 12:49 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
NX may also be an option. I haven't used it other than to play around with connecting to NoMachine's demo server, but it was actually usable over a dialup link.

Some more reading:
http://tuxarena.blogspot.com/2009/04/co ... chine.html
http://www.linuxplanet.com/linuxplanet/ ... ls/6567/1/
http://www.ubuntugeek.com/how-to-setup- ... repid.html
http://www.linux.com/archive/feature/116354


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 6:26 pm 
Offline
Senior Member

Joined: Tue Apr 29, 2008 6:26 pm
Posts: 58
Website: http://blog.shadypixel.com/
NX works significantly better than standard X forwarding over WANs.


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 8:48 pm 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
I realize that X forwarding may not be the best solution for remote control of a desktop.

The reason I want to use X forwarding, though, is to view image attachments easily. I could set up xv in my mailcap, and then it would display the images locally on my PC as long as I have PuTTY with X11 Forwarding configured correctly. This would be better for me than trying to use a VNC client just to check my e-mail. I am not even running an X desktop.

I am using a cable modem, not a dialup connection, and I would think the bandwidth would be more than sufficient.

I just ran another ltrace on a 1 pixel jpeg (631 bytes):


Code:
% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
 47.48  148.659076      193566       768 XAllocColor
 45.36  142.018798      184920       768 XGetImage
  3.02    9.444790     1049421         9 XNextEvent
  2.81    8.811661      244768        36 XGetNormalHints
  0.72    2.252987      375497         6 XInternAtom


I think the issue is that it is making a crazy amount of roundtrips on startup, so the latency is adding up. I am not sure if I can somehow adjust this with a buffer setting or if this is just the way the X protocol is designed.

I looked into an X protocol analyzer but I didn't see one available for Windows...


Top
   
 Post subject:
PostPosted: Sun Nov 08, 2009 8:53 pm 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
Maybe I just need to switch to a different program...

This URL had some relevant discussion.

http://fixunix.com/xwindows/358974-xquerycolor.html


Top
   
 Post subject:
PostPosted: Mon Nov 09, 2009 1:51 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
I'm not too familiar with netcat, but perhaps something like this might serve your needs rather than using X?
Code:
desktop$ while true ; do nc -l 12345 | display - ; done &
desktop$ ssh -R 12345:localhost:12345 user@linode.example.net

Then you could have your mail reader run this instead of xv:
Code:
linode$ nc 12345 < image.jpg

Not sure exactly if the way display handles standard input would allow this, but may be worth trying.

Failing that, it seems like there must be some image viewer out there that will accept images being pushed to it over a network port.


Top
   
 Post subject:
PostPosted: Mon Nov 09, 2009 1:53 pm 
Offline
Senior Member
User avatar

Joined: Tue May 26, 2009 3:29 pm
Posts: 1691
Location: Montreal, QC
nx still forwards NX, but it does compression and caching to eliminate most of the X round-trips:

http://en.wikipedia.org/wiki/NX_technology

It's generally a lot faster than VNC while providing similar functionality to X. You can forward just a single app (or all apps).

For example, when my friend comes over to my house to do some coding, he fires up NX and connects to his box back home. Up on his Windows desktop pops up KDevelop, kate, konsole, etc. They each show up as separate windows, as if they were local apps.


Top
   
 Post subject:
PostPosted: Mon Nov 09, 2009 3:03 pm 
Offline
Junior Member

Joined: Wed Nov 04, 2009 5:22 am
Posts: 27
Yeah, I could use something like netcat to shove the data back and forth over the connection, but it's a little kludgy.

Honestly, after more investigation it seems like those programs are just using a poor implementation for running via remote X. (If you are using a TrueColor display, for example, I don't think that there is a need to make all those round trips for XAllocColor.)
Code:
ltrace -c xv -vis TrueColor test.JPG

% time     seconds  usecs/call     calls      function
------ ----------- ----------- --------- --------------------
 47.27  143.337947      186637       768 XGetImage
 45.87  139.092035      181109       768 XAllocColor
  2.89    8.770029      243611        36 XGetNormalHints
  1.92    5.814834      581483        10 XNextEvent
  0.93    2.809923      255447        11 XSync


I just installed gpicview and it opens the 50k JPG file in around 4 seconds. I guess that would be my recommendation for anyone else wanting this functionality.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group