reorder some more fields to reduce padding

This commit is contained in:
Arvid Norberg 2013-11-26 02:23:33 +00:00
parent 629baa3622
commit d03d50b6a8
5 changed files with 24 additions and 22 deletions

View File

@ -103,8 +103,8 @@ bool TORRENT_EXTRA_EXPORT verify_message(lazy_entry const* msg, key_desc_t const
// to remove stale peers // to remove stale peers
struct peer_entry struct peer_entry
{ {
tcp::endpoint addr;
ptime added; ptime added;
tcp::endpoint addr;
bool seed; bool seed;
}; };

View File

@ -48,10 +48,10 @@ namespace libtorrent { namespace dht
struct node_entry struct node_entry
{ {
node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = 0xffff, bool pinged = false) node_entry(node_id const& id_, udp::endpoint ep, int roundtriptime = 0xffff, bool pinged = false)
: endpoint(ep) : id(id_)
, timeout_count(pinged ? 0 : 0xff) , endpoint(ep)
, rtt(roundtriptime) , rtt(roundtriptime)
, id(id_) , timeout_count(pinged ? 0 : 0xff)
{ {
#ifdef TORRENT_DHT_VERBOSE_LOGGING #ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = time_now(); first_seen = time_now();
@ -59,10 +59,10 @@ struct node_entry
} }
node_entry(udp::endpoint ep) node_entry(udp::endpoint ep)
: endpoint(ep) : id(0)
, timeout_count(0xff) , endpoint(ep)
, rtt(0xffff) , rtt(0xffff)
, id(0) , timeout_count(0xff)
{ {
#ifdef TORRENT_DHT_VERBOSE_LOGGING #ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = time_now(); first_seen = time_now();
@ -70,9 +70,9 @@ struct node_entry
} }
node_entry() node_entry()
: timeout_count(0xff) : id(0)
, rtt(0xffff) , rtt(0xffff)
, id(0) , timeout_count(0xff)
{ {
#ifdef TORRENT_DHT_VERBOSE_LOGGING #ifdef TORRENT_DHT_VERBOSE_LOGGING
first_seen = time_now(); first_seen = time_now();
@ -94,16 +94,20 @@ struct node_entry
address addr() const { return endpoint.address(); } address addr() const { return endpoint.address(); }
int port() const { return endpoint.port; } int port() const { return endpoint.port; }
union_endpoint endpoint;
// the number of times this node has failed to
// respond in a row
boost::uint8_t timeout_count;
// the average RTT of this node
boost::uint16_t rtt;
node_id id;
#ifdef TORRENT_DHT_VERBOSE_LOGGING #ifdef TORRENT_DHT_VERBOSE_LOGGING
ptime first_seen; ptime first_seen;
#endif #endif
node_id id;
union_endpoint endpoint;
// the average RTT of this node
boost::uint16_t rtt;
// the number of times this node has failed to
// respond in a row
boost::uint8_t timeout_count;
}; };
} } // namespace libtorrent::dht } } // namespace libtorrent::dht

View File

@ -181,11 +181,11 @@ private:
// port has to match // port has to match
node_entry* find_node(udp::endpoint const& ep, routing_table::table_t::iterator* bucket); node_entry* find_node(udp::endpoint const& ep, routing_table::table_t::iterator* bucket);
dht_settings const& m_settings;
// constant called k in paper // constant called k in paper
int m_bucket_size; int m_bucket_size;
dht_settings const& m_settings;
// (k-bucket, replacement cache) pairs // (k-bucket, replacement cache) pairs
// the first entry is the bucket the furthest // the first entry is the bucket the furthest
// away from our own ID. Each time the bucket // away from our own ID. Each time the bucket

View File

@ -111,10 +111,9 @@ private:
transactions_t m_transactions; transactions_t m_transactions;
udp_socket_interface* m_sock; udp_socket_interface* m_sock;
node_id m_our_id;
routing_table& m_table; routing_table& m_table;
ptime m_timer; ptime m_timer;
node_id m_random_number; node_id m_our_id;
int m_allocated_observers; int m_allocated_observers;
bool m_destructing; bool m_destructing;
}; };

View File

@ -162,10 +162,9 @@ rpc_manager::rpc_manager(node_id const& our_id
, routing_table& table, udp_socket_interface* sock) , routing_table& table, udp_socket_interface* sock)
: m_pool_allocator(observer_size, 10) : m_pool_allocator(observer_size, 10)
, m_sock(sock) , m_sock(sock)
, m_our_id(our_id)
, m_table(table) , m_table(table)
, m_timer(time_now()) , m_timer(time_now())
, m_random_number(generate_random_id()) , m_our_id(our_id)
, m_allocated_observers(0) , m_allocated_observers(0)
, m_destructing(false) , m_destructing(false)
{ {