#
# patch "AUTHORS"
# from [1bc23bee8e818ed6bc3b2d173b0f6435cbc92832]
# to [ff466bec33fb81e11e8f7dc8cc425e89ee70f745]
#
# patch "ChangeLog"
# from [5293c86ecc14f6f36a61630082f5cd634840d21f]
# to [f15c2359c3a9d16158dcac9119c14fd4b68d8194]
#
# patch "constants.cc"
# from [2258f6165b6db8f8c952f97aaacf0addbbed060f]
# to [dcbffe20599c26310957ee7c1310a44ae93dc2a0]
#
# patch "netsync.cc"
# from [c0daeb05b828a4e64c62379ceb8f2113c3f8b1ae]
# to [8cd3b5995624e0fe9d57a9954b88aef6944474f0]
#
--- AUTHORS
+++ AUTHORS
@@ -60,6 +60,7 @@
Matthew Gregan
Riccardo Ghetta
Ethan Blanton
+ Eric Anderson
supporting files:
-----------------
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,12 @@
+2005-06-28 Matt Johnston
+
+ * constants.cc: increase db_version_cache_sz to 7 MB
+ * netsync.cc: use a deque rather than a single
+ string buffer for outbuf.
+ * netsync.cc (arm): only queue data when there is
+ available space
+ * AUTHORS: added Eric Anderson
+
2005-06-26 Matt Johnston
* transforms.hh: remove extraneous #ifdef
--- constants.cc
+++ constants.cc
@@ -44,8 +44,11 @@
// truncated.
size_t const db_log_line_sz = 70;
- // size in bytes of the database xdelta version reconstruction cache
- size_t const db_version_cache_sz = 1 << 20;
+ // size in bytes of the database xdelta version reconstruction cache.
+ // the value of 7 MB was determined as the optimal point after timing
+ // various values with a pull of the monotone repository - it could
+ // be tweaked further.
+ size_t const db_version_cache_sz = 7 * (1 << 20);
// size of a line of text in the log buffer, beyond which log lines will be
// truncated.
--- netsync.cc
+++ netsync.cc
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
#include
@@ -261,7 +262,12 @@
Netxx::Stream str;
string inbuf;
- string outbuf;
+ // deque of pair
+ deque< pair > outbuf;
+ // the total data stored in outbuf - this is
+ // used as a valve to stop too much data
+ // backing up
+ size_t outbuf_size;
netcmd cmd;
bool armed;
@@ -481,7 +487,7 @@
fd(sock),
str(sock, to),
inbuf(""),
- outbuf(""),
+ outbuf_size(0),
armed(false),
pattern(""),
pattern_re(".*"),
@@ -788,7 +794,12 @@
session::write_netcmd_and_try_flush(netcmd const & cmd)
{
if (!encountered_error)
- cmd.write(outbuf, write_hmac);
+ {
+ string buf;
+ cmd.write(buf, write_hmac);
+ outbuf.push_back(make_pair(buf, 0));
+ outbuf_size += buf.size();
+ }
else
L(F("dropping outgoing netcmd (because we're in error unwind mode)\n"));
// FIXME: this helps keep the protocol pipeline full but it seems to
@@ -1346,14 +1357,23 @@
session::write_some()
{
I(!outbuf.empty());
- Netxx::signed_size_type count = str.write(outbuf.data(),
- std::min(outbuf.size(),
+ size_t writelen = outbuf.front().first.size() - outbuf.front().second;
+ Netxx::signed_size_type count = str.write(outbuf.front().first.data() + outbuf.front().second,
+ std::min(writelen,
constants::bufsz));
if (count > 0)
{
- outbuf.erase(0, count);
- L(F("wrote %d bytes to fd %d (peer %s), %d remain in output buffer\n")
- % count % fd % peer_id % outbuf.size());
+ if ((size_t)count == writelen)
+ {
+ outbuf_size -= outbuf.front().first.size();
+ outbuf.pop_front();
+ }
+ else
+ {
+ outbuf.front().second += count;
+ }
+ L(F("wrote %d bytes to fd %d (peer %s)\n")
+ % count % fd % peer_id);
mark_recent_io();
if (byte_out_ticker.get() != NULL)
(*byte_out_ticker) += count;
@@ -3193,9 +3213,11 @@
{
if (!armed)
{
+ if (outbuf_size > constants::bufsz * 10)
+ return false; // don't pack the buffer unnecessarily
+
if (cmd.read(inbuf, read_hmac))
{
-// inbuf.erase(0, cmd.encoded_size());
armed = true;
}
}