Gnutella Forums  

Go Back   Gnutella Forums > Current Gnutella Client Forums > Phex (Cross-platform) > Development & Coding > Development Open Discussion
Register FAQ The Twelve Commandments Members List Calendar Arcade Find the Best VPN Today's Posts

Development Open Discussion Anything else about the Phex development


 
 
LinkBack Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3 (permalink)  
Old August 29th, 2008
Novicius
 
Join Date: August 26th, 2008
Posts: 2
mvchante is flying high
Default

Removing the synchronized added in the diff you mentioned does indeed eliminate the GUI lag; however, I presume those synchronized's are needed?


On a broader look: When the GUI renders, it gets the most current values from BandwidthController by-way-of SWDownloadFile . This causes the EventDispatchThread to block until it can retrieve this value from the data transfer thread.


As a test, I implemented a cache (see below). This showed a measurable improvement in GUI response.



I believe the ultimate solution would be to have SWDownloadFile listen to BandwidthController to receive updated values when available /instead of/ having SWDownloadFile query BandwidthController for each request and thus blocking.


Comments?









Code:


    public static class EdtCache
    {
        private final SWDownloadFile download   ;
        private final long           updateRate ;

        private long lastUpdate             ;
//        private int  shortTermTransferRate  ;
        private int  longTermTransferRate   ;
        private long transferSpeed          ;
        private long downloadThrottlingRate ;

        public EdtCache(SWDownloadFile download, long updateRate)
        {
            this.download = download;
            this.updateRate = updateRate;
            update();
        }

        private void update()
        {
try {
//            shortTermTransferRate   = download.getShortTermTransferRate  ();
            longTermTransferRate    = download.getLongTermTransferRate   ();
            transferSpeed           = download.getTransferSpeed          ();
            downloadThrottlingRate  = download.getDownloadThrottlingRate ();
            lastUpdate              = System.currentTimeMillis();
} catch (RuntimeException re) {
    re.printStackTrace();
    throw re;
}
        }

        private boolean needsUpdate() { return System.currentTimeMillis() - lastUpdate > updateRate; }

//        public int getShortTermTransferRate()
//        {
//            if (needsUpdate()) update();
//            return shortTermTransferRate;
//        }

        public int getLongTermTransferRate()
        {
            if (needsUpdate()) update();
            return longTermTransferRate;
        }

        public long getTransferSpeed()
        {
            if (needsUpdate()) update();
            return transferSpeed;
        }

        public long getDownloadThrottlingRate()
        {
            if (needsUpdate()) update();
            return downloadThrottlingRate;
        }

    }

Cheers,
M. V`Chante

Last edited by mvchante; August 29th, 2008 at 10:24 PM. Reason: typo
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 08:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.