Last Comment Bug 897910 - about:networking - calculate total amount of data sent / received
: about:networking - calculate total amount of data sent / received
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Networking (show other bugs)
: 21 Branch
: x86_64 Linux
: -- normal (vote)
: mozilla25
Assigned To: Robert Bindar
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-25 03:04 PDT by Robert Bindar
Modified: 2013-07-29 16:40 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
data usage (4.60 KB, patch)
2013-07-25 03:13 PDT, Robert Bindar
no flags Details | Diff | Splinter Review
data usage v2 (5.16 KB, patch)
2013-07-26 09:37 PDT, Robert Bindar
mcmanus: review+
Details | Diff | Splinter Review
data usage (5.16 KB, patch)
2013-07-26 14:15 PDT, Robert Bindar
no flags Details | Diff | Splinter Review

Description Robert Bindar 2013-07-25 03:04:13 PDT
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0 (Beta/Release)
Build ID: 20130620122336

Steps to reproduce:

We need to trace the total number of bytes sent / received.
Comment 1 Robert Bindar 2013-07-25 03:13:00 PDT
Created attachment 780892 [details] [diff] [review]
data usage

I've used the already existent variables that count the number of bytes sent / received through a socket (an active one) and I've added 2 counters for the bytes transmitted through the now-closed sockets.
Comment 2 Valentin Gosu [:valentin] 2013-07-25 11:01:48 PDT
Comment on attachment 780892 [details] [diff] [review]
data usage

Review of attachment 780892 [details] [diff] [review]:
-----------------------------------------------------------------

I was thinking we could do this without a lock, but from what I can see, locking is already used when Reading/Writing:
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsSocketTransport2.cpp#350
I think we could just update the values at that point. Patrick? What do you think?
Comment 3 Patrick McManus [:mcmanus] 2013-07-26 05:43:08 PDT
Comment on attachment 780892 [details] [diff] [review]
data usage

Review of attachment 780892 [details] [diff] [review]:
-----------------------------------------------------------------

you don't need explicit locks because this is all being done from the socket thread and those values are only updated on the socket thread. If you were trying to read it from the main thread then you would need the lock to prevent reading partial updates of the 64 bit counters on some platforms.

::: netwerk/base/src/Dashboard.cpp
@@ +47,5 @@
>          gSocketTransportService->GetSocketConnections(&mSock.data);
>      nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &Dashboard::GetSockets);
>      mSock.thread->Dispatch(event, NS_DISPATCH_NORMAL);
> +    mSock.totalSent = gSocketTransportService->GetSentBytes();
> +    mSock.totalRecv = gSocketTransportService->GetReceivedBytes();

I'm pretty sure these want to be moved up to before you dispatch the event and in the if(gTransportService){} block

::: netwerk/base/src/nsSocketTransportService2.h
@@ +74,5 @@
>          return mActiveCount + mIdleCount < gMaxCount;
>      }
>  
>      // Called by the networking dashboard
>      // Fills the passed array with socket information

document that these dashboard methods are socket thread only

@@ +163,1 @@
>      

can you fix this bit of whitespace? (not from your patch)
Comment 4 Robert Bindar 2013-07-26 09:37:26 PDT
Created attachment 781758 [details] [diff] [review]
data usage v2
Comment 6 Patrick McManus [:mcmanus] 2013-07-26 13:35:21 PDT
Comment on attachment 781758 [details] [diff] [review]
data usage v2

Review of attachment 781758 [details] [diff] [review]:
-----------------------------------------------------------------

::: netwerk/base/src/nsSocketTransportService2.h
@@ +158,5 @@
>      void   InitMaxCount();
> +
> +    // Total bytes number transfered through all the sockets except active ones
> +    uint64_t mSentBytesCount;
> +    uint64_t mReceivedBytesCount;    

pls remove this trailing whitespace
Comment 7 Robert Bindar 2013-07-26 14:15:33 PDT
Created attachment 781930 [details] [diff] [review]
data usage

r=mcmanus
Comment 8 Ryan VanderMeulen [:RyanVM] 2013-07-29 09:20:49 PDT
https://hg.mozilla.org/integration/fx-team/rev/b05c1dba6ad9
Comment 9 Ryan VanderMeulen [:RyanVM] 2013-07-29 15:47:36 PDT
https://hg.mozilla.org/mozilla-central/rev/b05c1dba6ad9

Note You need to log in before you can comment on or make changes to this bug.