18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Performance problem in Sahi

richard.lirichard.li Members
edited November -1 in Sahi - Open Source
I have discovered a few performance problems in Sahi, especially when using it against large GWT applications. I am working out some fixes, will update you later.

Comments

  • richard.lirichard.li Members
    edited December 2009
    The first problem found is in the ProxyProcessor.isHostTheProxy(), it will try to find the ip of the non-existing host: "sahi.example.com" and cause a large delay for the dns to timeout. I fixed it as follows:

    try
    {
    if (host.equals("sahi.example.com"))
    {
    return false;
    }

    String hostAddress = InetAddress.getByName(host).getHostAddress();

    return hostAddress.equals("127.0.0.1") || hostAddress.equals(InetAddress.getLocalHost().getHostAddress());
    }
    catch (Exception e)
    {
    return false;
    }

    But I think the bast way to do this is to define the sahi.example.com as a constant so that all codes refer to this domain can point to a single version. This will speed up page loading quite a bit.
  • The second problem discovered is the stream filter architecture. It seems it uses a lot of piped streams and threads to implement, however the best way in doing this should be using filtered streams approached so that no unnecessary threads is required. I will try to work this out and see how much performance can be improved.
  • narayannarayan Administrators
    Hi Richard,

    Thanks for the inputs and do let us know what you find. We are ourselves looking for ways to speed up Sahi further, and your findings will be very valuable to us.

    ProxyProcessor.isHostTheProxy() is called only for urls which do not have /_s_/ in their urls. All calls to sahi.example.com always have _s_ in their urls so they will never reach ProxyProcessor.isHostTheProxy(). Let us know if you noticed something different.

    We are also looking at reducing the number of injected files at the top to reduce round trips.

    Do keep us posted.

    Thanks and regards,
    Narayan
  • Actually I found ProxyProcessor.isHostTheProxy()'s slowness is by profiling and found that a lot of time required to execute InetAddress.getByName(host), and when I trace in, I found the host name is sahi.example.com, so there maybe some bugs in other places causing this problem.
  • Another slowness discovered is the filter architecture used. Your design uses one thread per filter to do the copying, this cause a lot of threads intercommunication problem and slow down the filtering process. I have made a wrapper change the multi-thread model to a simple filter stream model and it speed up a lot.

    Another slowness is due to the SSL socket connection, I have observed some place you have not used buffered stream for I/O and cause slowness in SSL encryption, also increase the default buffer size can help a lot in this case, I have changed all bufferedstream to use 64K buffer instead of 8K buffer.

    The overall speedup is 5 mins vs 20-30secs
  • narayannarayan Administrators
    Awesome Richard! Would you be willing to share it?
  • Sure, I have to do some code cleanup first, but how may I upload the changes? Or I may commit the change to you code base if you permitted.
  • narayannarayan Administrators
    You could just zip up the source and send it across to my email id. Let us review it before you check it in.

    Thanks again,
    Narayan
  • Just send you an e-mail with modified sources with the reason of my changes, hope this helps.
  • narayannarayan Administrators
    Thanks a lot. I will keep you updated.
Sign In or Register to comment.