mirror of
https://github.com/ceph/ceph
synced 2025-02-19 17:08:05 +00:00
buffer: Add _memcopy_count to track total count of memcopy by rebuild/rebuild_page_aligned/c_str.
Using thie filed, we know the payload of rebuild/rebuild_page_aligned/c_str and tune performance accroding. Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com> Reviewed-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
e7fb00392e
commit
8ba504dee8
@ -955,6 +955,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
|
||||
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);
|
||||
@ -1111,6 +1112,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
|
||||
nb.copy_in(pos, it->length(), it->c_str());
|
||||
pos += it->length();
|
||||
}
|
||||
_memcopy_count += pos;
|
||||
_buffers.clear();
|
||||
_buffers.push_back(nb);
|
||||
}
|
||||
@ -1150,6 +1152,7 @@ void buffer::list::rebuild_aligned(unsigned align)
|
||||
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());
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public:
|
||||
// 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:
|
||||
@ -317,14 +317,14 @@ 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;
|
||||
@ -333,8 +333,8 @@ public:
|
||||
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
|
||||
@ -363,6 +363,7 @@ public:
|
||||
void clear() {
|
||||
_buffers.clear();
|
||||
_len = 0;
|
||||
_memcopy_count = 0;
|
||||
last_p = begin();
|
||||
}
|
||||
void push_front(ptr& bp) {
|
||||
|
@ -927,6 +927,7 @@ void FileJournal::align_bl(off64_t pos, bufferlist& bl)
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user