Skip to contentSkip to conversation

disabling buffer::raw crc cache

DISCUSSION Evgeniy Firsov 4 participants 10 messages Nov 11, 2015

lore
Share & tools
lore
#0 lore raw

Hello, Guys!

While running CPU bound 4k block workload, I found that disabling crc cache in the buffer::raw gives around 7% performance improvement.

If there is no strong use case which benefit from that cache, we would remove it entirely, otherwise conditionally enable it based on the object size.

‹
Evgeniy

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

Ah, I confuse that why the crc cache logic would exhaust so much cpu.

2015-11-11 15:27 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 16 lines

Hello, Guys!

While running CPU bound 4k block workload, I found that disabling crc cache in the buffer::raw gives around 7% performance improvement.

If there is no strong use case which benefit from that cache, we would remove it entirely, otherwise conditionally enable it based on the object size.

‹
Evgeniy

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 6 lines
Regards,
xinze
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Rb-tree construction, insertion, which needs memory allocation, mutex lock, unlock is more CPU expensive then streamlined crc calculation of sometimes 100 bytes or less.

Quoted 26 lines · 池信泽

Ah, I confuse that why the crc cache logic would exhaust so much cpu.

2015-11-11 15:27 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 17 lines

Hello, Guys!

While running CPU bound 4k block workload, I found that disabling crc cache in the buffer::raw gives around 7% performance improvement.

If there is no strong use case which benefit from that cache, we would remove it entirely, otherwise conditionally enable it based on the object
size.

‹
Evgeniy

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Regards,
xinze
#3 lore raw

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc. we call bufferlist::crc32 when sending or receiving message and writing filejournal.
I miss something critical?

I am agree with you that the benefit from that cache cache is every limit.

2015-11-11 16:25 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 33 lines

Rb-tree construction, insertion, which needs memory allocation, mutex lock, unlock is more CPU expensive then streamlined crc calculation of sometimes 100 bytes or less.

Quoted 26 lines · 池信泽

Ah, I confuse that why the crc cache logic would exhaust so much cpu.

2015-11-11 15:27 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 10 lines

Hello, Guys!

While running CPU bound 4k block workload, I found that disabling crc cache in the buffer::raw gives around 7% performance improvement.

If there is no strong use case which benefit from that cache, we would remove it entirely, otherwise conditionally enable it based on the object
size.

Quoted 7 lines

‹
Evgeniy

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Regards,
xinze

Signature · 6 lines
Regards,
xinze
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
In reply to Evgeniy Firsov
Quoted 1 line
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

So we may need to add some option to enable or disable it, or some identifier to instruct bufferlist wheher crc should be cached when initiating a new bufferlist. I think it may still be useful on the platform without hardware crc acceleration or large chunks writing (as it may relate to the length of buffer::ptr). So we can bypass the small buffer::ptr without crc cache Or also don't cache the things like pg_info, attrs as they are always not reused in FileJournal writing?
Regards
Ning Yao

2015-11-11 16:25 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 4 lines

Rb-tree construction, insertion, which needs memory allocation, mutex lock, unlock is more CPU expensive then streamlined crc calculation of sometimes 100 bytes or less.

Quoted 29 lines
Quoted 26 lines · 池信泽

Ah, I confuse that why the crc cache logic would exhaust so much cpu.

2015-11-11 15:27 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 10 lines

Hello, Guys!

While running CPU bound 4k block workload, I found that disabling crc cache in the buffer::raw gives around 7% performance improvement.

If there is no strong use case which benefit from that cache, we would remove it entirely, otherwise conditionally enable it based on the object
size.

Quoted 7 lines

‹
Evgeniy

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Regards,
xinze

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
Quoted 3 lines
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

Oh, no, it will be hit in FileJournal writing
Regards
Ning Yao

2015-11-11 18:03 GMT+08:00 Ning Yao <[email protected]>:

Quoted 16 lines
Quoted 1 line
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

So we may need to add some option to enable or disable it, or some identifier to instruct bufferlist wheher crc should be cached when initiating a new bufferlist. I think it may still be useful on the platform without hardware crc acceleration or large chunks writing (as it may relate to the length of buffer::ptr). So we can bypass the small buffer::ptr without crc cache Or also don't cache the things like pg_info, attrs as they are always not reused in FileJournal writing?
Regards
Ning Yao

Quoted 34 lines

2015-11-11 16:25 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 33 lines

Rb-tree construction, insertion, which needs memory allocation, mutex lock, unlock is more CPU expensive then streamlined crc calculation of sometimes 100 bytes or less.

Quoted 26 lines · 池信泽

Ah, I confuse that why the crc cache logic would exhaust so much cpu.

2015-11-11 15:27 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 10 lines

Hello, Guys!

While running CPU bound 4k block workload, I found that disabling crc cache in the buffer::raw gives around 7% performance improvement.

If there is no strong use case which benefit from that cache, we would remove it entirely, otherwise conditionally enable it based on the object
size.

Quoted 7 lines

‹
Evgeniy

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Regards,
xinze

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

Oh, no, it will be hit in FileJournal writing

Still miss as buffer::ptr length diff with ::encode(crc, bl), right? So the previous ebl.crc32c(0) calculation would be also no need to cache.
Regards
Ning Yao

2015-11-11 18:05 GMT+08:00 Ning Yao <[email protected]>:

Quoted 59 lines
Quoted 3 lines
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

Oh, no, it will be hit in FileJournal writing
Regards
Ning Yao

2015-11-11 18:03 GMT+08:00 Ning Yao <[email protected]>:

Quoted 50 lines
Quoted 1 line
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

So we may need to add some option to enable or disable it, or some identifier to instruct bufferlist wheher crc should be cached when initiating a new bufferlist. I think it may still be useful on the platform without hardware crc acceleration or large chunks writing (as it may relate to the length of buffer::ptr). So we can bypass the small buffer::ptr without crc cache Or also don't cache the things like pg_info, attrs as they are always not reused in FileJournal writing?
Regards
Ning Yao

2015-11-11 16:25 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 33 lines

Rb-tree construction, insertion, which needs memory allocation, mutex lock, unlock is more CPU expensive then streamlined crc calculation of sometimes 100 bytes or less.

Quoted 26 lines · 池信泽

Ah, I confuse that why the crc cache logic would exhaust so much cpu.

2015-11-11 15:27 GMT+08:00 Evgeniy Firsov <[email protected]>:

Quoted 10 lines

Hello, Guys!

While running CPU bound 4k block workload, I found that disabling crc cache in the buffer::raw gives around 7% performance improvement.

If there is no strong use case which benefit from that cache, we would remove it entirely, otherwise conditionally enable it based on the object
size.

Quoted 7 lines

‹
Evgeniy

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Regards,
xinze

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw
Quoted 7 lines · Ning Yao
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

Oh, no, it will be hit in FileJournal writing

Still miss as buffer::ptr length diff with ::encode(crc, bl), right? So the previous ebl.crc32c(0) calculation would be also no need to cache.

How about just skipping the cache logic if the raw length is less than some threshold? Say, 16KB or something? That would cover the _write_log case (small buffer) and more generally avoid the fixed overhead of caching when recalculating is cheap.

This was originally added with large writes in mind to avoid the crc recalculation during journaling on armv7l. It is presumably also helping now that we have the opportunistic whole-object checksums for full or sequential writes.

sage

#8 lore raw

2015-11-11 21:13 GMT+08:00 Sage Weil <[email protected]>:

Quoted 14 lines · Ning Yao
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

Oh, no, it will be hit in FileJournal writing

Still miss as buffer::ptr length diff with ::encode(crc, bl), right? So the previous ebl.crc32c(0) calculation would be also no need to cache.

How about just skipping the cache logic if the raw length is less than some threshold? Say, 16KB or something? That would cover the _write_log case (small buffer) and more generally avoid the fixed overhead of caching when recalculating is cheap.

Quoted 4 lines

This was originally added with large writes in mind to avoid the crc recalculation during journaling on armv7l. It is presumably also helping now that we have the opportunistic whole-object checksums for full or sequential writes.

Reasonable, and we may also reconsider whether map<pair<size_t,size_t>, <int, int> > is really needed. The common case seems always use the same offset and length. Is it better for us to just cache the last crc result (only one item is enough efficient)?

Regards
Ning Yao

#9 lore raw
Quoted 20 lines · Ning Yao

2015-11-11 21:13 GMT+08:00 Sage Weil <[email protected]>:

Quoted 14 lines · Ning Yao
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

the code logic would touch crc cache is bufferlist::crc32c and invalidate_crc.

Also for pg_log::_write_log(), but seems it is always miss and use at once, no need to cache crc actually?

Oh, no, it will be hit in FileJournal writing

Still miss as buffer::ptr length diff with ::encode(crc, bl), right? So the previous ebl.crc32c(0) calculation would be also no need to cache.

How about just skipping the cache logic if the raw length is less than some threshold? Say, 16KB or something? That would cover the _write_log case (small buffer) and more generally avoid the fixed overhead of caching when recalculating is cheap.

Quoted 4 lines

This was originally added with large writes in mind to avoid the crc recalculation during journaling on armv7l. It is presumably also helping now that we have the opportunistic whole-object checksums for full or sequential writes.

Quoted 4 lines

Reasonable, and we may also reconsider whether map<pair<size_t,size_t>, <int, int> > is really needed. The common case seems always use the same offset and length. Is it better for us to just cache the last crc result (only one item is enough efficient)?

Yeah, or maybe a fixed size array with a #define size of maybe 2 or 3.

sage