lantern icon indicating copy to clipboard operation
lantern copied to clipboard

allBytes.rate keep on increasing

Open ed2k opened this issue 12 years ago • 14 comments

copy ui issue from https://github.com/getlantern/lantern-ui/issues/77# to consolidate all lantern related issues.

seem my peering rates in give mode doesn't look right. it keeps on increasing, not monotonically though, but over couple of hours I got close to 800K/s, which I know it is not possible by comparing with my total traffic.

checking the code, https://github.com/getlantern/lantern-ui/blob/master/app/js/services.js#L322 allBytes.rate just simply take += peer.rate, it never reset to zero. is this a bug?

-- it looks like we could just keep a local variable there and then set it. Seems like something like this is closer to what we want:

var peerTotal = 0;
for (var peerid in flashlightPeers) {
        var peer = flashlightPeers[peerid];

        // Consider peer connected if it's been less than x seconds since
        // lastConnected
        var lastConnected = Date.parse(peer.lastConnected);
        var delta = new Date().getTime() - Date.parse(peer.lastConnected);
        peer.connected = delta < 30000;

        // Add peer to model
        model.peers.push(peer);

        if (shouldUpdateInstanceStats) {
          // Update total bytes up/dn
          peerTotal += peer.bpsUpDn;
        }
}
model.instanceStats.allBytes.rate = peerTotal;

ed2k avatar Sep 25 '14 03:09 ed2k

Nice investigative work. This is likely the same root cause as #1804.

oxtoacart avatar Sep 25 '14 13:09 oxtoacart

The suggested fix isn't quite right, as there are also peers reported from the Java back-end process. What we need to do is calculate the allBytes.rate by iterating across all model.peers and summing their bpsUpDn.

@ed2k Want to try it and give us a PR?

oxtoacart avatar Sep 25 '14 13:09 oxtoacart

with the suggested fix, if it is missing some peers I would expect the number will be low or zero most of the time. Actually the result is over night it is still increasing to hundreds of KB/s. I am not very clear how those peers got the raw data. From server? or flashlight? which log I can turn on to see the raw date reporting (per peer). I am expecting a place that can print IP, bytes etc.

ed2k avatar Sep 26 '14 03:09 ed2k

more diggings. I look at the cometd data send (sync) to GUI client. Seems services.js cares about two pieces to display the allBytes.rate, one is the /peers, it proves bytesUpDn. fore each peer. That looks like a total value. The other is /instanceStats, it only provides allBytes.total. the way we put all peers.bytesUpDn into rate doesn't make sense.

ed2k avatar Sep 26 '14 04:09 ed2k

So, the key thing to know is that we have two back-ends feeding us this data, the main Lantern backend (through the cometd service) and the flashlight instance through a websocket. To figure out the total rate, we need to get the rate provided by Lantern and add the rates of all peers reported by flashlight to this.

There were a couple of problems here:

  1. flashlight wasn't updating the peer's rate after the peer's activity stopped.
  2. The logic for totaling the rates in the UI wasn't very clearly expressed. I think it actually worked, but I've refactored it to make it clearer what's going on.

Unfortunately, the master branch of lantern-ui is currently broken, so I can't close this ticket until this PR is resolved.

oxtoacart avatar Sep 26 '14 14:09 oxtoacart

Oh wow I'm somehow just now realizing all that new code went into master. @atavism can you role all those changes back and put them on a branch when you can? We really always want all master/devel branches to always be in a shippable state and to do all merges to them through PRs. Sorry if that wasn't clear!

myleshorton avatar Sep 27 '14 05:09 myleshorton

looking at the branch strategy, it does use master branch as the main development branch https://github.com/getlantern/lantern/wiki/%5Bdevelopers%5D-Branch-Strategy

ed2k avatar Sep 27 '14 06:09 ed2k

@myleshorton Yeah, totally. Just undid my merge and cherry-picked Ox's update. My mistake: I thought you had said not to do any PRs on lantern-ui and instead PR from lantern after merging changes to master on lantern-ui. To be clear: all of my changes were already on a separate branch.

atavism avatar Sep 27 '14 06:09 atavism

@atavism I just pulled the latest from master, and your changes still appear to be there ... The only thing that seems to have changed is that some whitespace was taken out of index.html.

oxtoacart avatar Sep 27 '14 08:09 oxtoacart

@oxtoacart https://github.com/getlantern/lantern-ui/commits/master I'm not seeing my commits anywhere?

git log -n 3
commit c4563e5d9c0e99d24c1a4a61f12d9adae5b5abae
Author: Todd Blose <[email protected]>
Date:   Fri Sep 26 23:02:05 2014 -0700

    undo UI refresh merge to master

commit 206a1cab8bf55b92eb529b4cb0254f3e2341d445
Author: Ox Cart <[email protected]>
Date:   Fri Sep 26 09:36:56 2014 -0500

    getlantern/lantern#1848 Building total bps up/down rate as sum of lantern rate plus flashlight rate

commit 89eba387085ffbf7abe146d184fb77494530f6df
Merge: f7dd22d a4ef240
Author: myleshorton <[email protected]>
Date:   Thu Sep 4 00:28:33 2014 -0500

    Merge pull request #76 from hpshelton/master

    Support tests in Travis CI and locally through 'npm test'

atavism avatar Sep 27 '14 18:09 atavism

Weird. Here's what I see:

➜  lantern-ui git:(master) git checkout master
Already on 'master'
Your branch is ahead of 'origin/master' by 12 commits.
  (use "git push" to publish your local commits)
➜  lantern-ui git:(master) git pull
Already up-to-date.

git log shows

commit b73f306c2cd1970fd0f9b3d2f4aade2efe50676e
Merge: 6fa7dc4 c4563e5
Author: Ox Cart <[email protected]>
Date:   Sat Sep 27 03:40:22 2014 -0500

    Merge branch 'master' of https://github.com/getlantern/lantern-ui

commit c4563e5d9c0e99d24c1a4a61f12d9adae5b5abae
Author: Todd Blose <[email protected]>
Date:   Fri Sep 26 23:02:05 2014 -0700

    undo UI refresh merge to master

commit 206a1cab8bf55b92eb529b4cb0254f3e2341d445
Author: Ox Cart <[email protected]>
Date:   Fri Sep 26 09:36:56 2014 -0500

    getlantern/lantern#1848 Building total bps up/down rate as sum of lantern rate plus flashlight rate

commit 6fa7dc4f0662a20e41bf88c41cc1c68b6e30464a
Author: Ox Cart <[email protected]>
Date:   Fri Sep 26 09:36:56 2014 -0500

    getlantern/lantern#1848 Building total bps up/down rate as sum of lantern rate plus flashlight rate

commit 882c0df179990b42d425d67019776a2b38d38989
Merge: 7f4b184 e10818e
Author: Todd Blose <[email protected]>
Date:   Sun Sep 21 15:07:27 2014 -0700

    add UI refresh

commit 7f4b184b708d02d5e8a25f78a7fec434182cfe44
Merge: 432940c 89eba38
Author: Todd Blose <[email protected]>
Date:   Sun Sep 21 15:07:20 2014 -0700

    add UI refresh

commit e10818ed8104dd5c7987f2f4d29b205df5028a5d
Merge: c1489d2 432940c
Author: Todd Blose <[email protected]>
Date:   Sun Sep 21 15:05:52 2014 -0700

    fix blur when zoomed in

So apparently I still have your commits in my clone. How did you remove your changes?

oxtoacart avatar Sep 27 '14 18:09 oxtoacart

I went back to the previous commit before I merged my updates and also cherry picked your changes:

git checkout 89eba387085ffbf7abe146d184fb77494530f6df
git cherry-pick 6fa7dc4f0662a20e41bf88c41cc1c68b6e30464a

then committed that updated copy. If you have no local changes now, does calling git reset --hard origin/master fix things?

atavism avatar Sep 27 '14 18:09 atavism

That did it, thanks!

oxtoacart avatar Sep 27 '14 18:09 oxtoacart

Thanks @atavism and @oxtoacart and totally sorry for the confusion on it @atavism - I realized we probably never went over the process for things like that, and it's totally possible I misspoke. Thanks for cleaning that up!

myleshorton avatar Sep 27 '14 21:09 myleshorton