void buffer::list::swap(list& other)
{
std::swap(_len, other._len);
+ std::swap(_memcopy_count, other._memcopy_count);
_buffers.swap(other._buffers);
append_buffer.swap(other.append_buffer);
//last_p.swap(other.last_p);
nb.copy_in(pos, it->length(), it->c_str());
pos += it->length();
}
+ _memcopy_count += pos;
_buffers.clear();
_buffers.push_back(nb);
}
if (!(unaligned.is_contiguous() && unaligned._buffers.front().is_aligned(align))) {
ptr nb(buffer::create_aligned(unaligned._len, align));
unaligned.rebuild(nb);
+ _memcopy_count += unaligned._len;
}
_buffers.insert(p, unaligned._buffers.front());
}
// my private bits
std::list<ptr> _buffers;
unsigned _len;
-
+ unsigned _memcopy_count; //the total of memcopy using rebuild().
ptr append_buffer; // where i put small appends.
public:
public:
// cons/des
- list() : _len(0), last_p(this) {}
- list(unsigned prealloc) : _len(0), last_p(this) {
+ list() : _len(0), _memcopy_count(0), last_p(this) {}
+ list(unsigned prealloc) : _len(0), _memcopy_count(0), last_p(this) {
append_buffer = buffer::create(prealloc);
append_buffer.set_length(0); // unused, so far.
}
~list() {}
- list(const list& other) : _buffers(other._buffers), _len(other._len), last_p(this) { }
+ list(const list& other) : _buffers(other._buffers), _len(other._len), _memcopy_count(other._memcopy_count),last_p(this) { }
list& operator= (const list& other) {
if (this != &other) {
_buffers = other._buffers;
return *this;
}
+ unsigned get_memcopy_count() const {return _memcopy_count; }
const std::list<ptr>& buffers() const { return _buffers; }
-
void swap(list& other);
unsigned length() const {
#if 0
void clear() {
_buffers.clear();
_len = 0;
+ _memcopy_count = 0;
last_p = begin();
}
void push_front(ptr& bp) {
if (directio && (!bl.is_page_aligned() ||
!bl.is_n_page_sized())) {
bl.rebuild_page_aligned();
+ dout(10) << __func__ << " total memcopy: " << bl.get_memcopy_count() << dendl;
if ((bl.length() & ~CEPH_PAGE_MASK) != 0 ||
(pos & ~CEPH_PAGE_MASK) != 0)
dout(0) << "rebuild_page_aligned failed, " << bl << dendl;