Count bytes spent on answering directory requests
Mike wants to know for his bandwidth weights how many bytes we're writing and reading for directory requests as compared to all bytes. We could add two new lines in the style of write-history and read-history that declare how many bytes were spent on directory requests, including both direct connections to the Dir port and tunneled requests via BEGIN_DIR cells.
Here are some example numbers from my test relay's state file, together with the write-history and read-history lines for comparison:
BWHistoryReadEnds 2010-08-03 08:45:44
BWHistoryReadValues [...],185844736,205917184,207345664,17137133
BWHistoryWriteEnds 2010-08-03 08:45:44
BWHistoryWriteValues [...],223923200,240807936,239798272,21942640
BWHistoryDirReadEnds 2010-08-03 08:43:32
BWHistoryDirReadValues [...]38042624,32221184,32626688,8438197
BWHistoryDirWriteEnds 2010-08-03 08:43:32
BWHistoryDirWriteValues [...],684032,542720,642048,167731
The interval ends of read/written bytes and read/written dir bytes don't match, because the relay was measuring bytes before, but not dir bytes.
I'm wondering why we're reading that many more dir bytes than we are writing. Is something wrong with my patch?
Please find branch dirbytes in my public repository that has the patch. Note that the dirreq-{write,read}-history lines are not added to extra-info descriptors in that patch, but only written to the local state file. Once we're done reviewing the patch, we need to change the r<2 part in rep_hist_get_bandwidth_lines() to r<4 (search for "TODO" in the patch).