cryptomb: add queue size statistics#19180
Conversation
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
|
Hi @VillePihlava, welcome and thank you for your contribution. We will try to review your Pull Request as quickly as possible. In the meantime, please take a look at the contribution guidelines if you have not done so already. |
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
jmarantz
left a comment
There was a problem hiding this comment.
looks great generally, with one concern/question about how frequently we are going to be doing stats symbol-table lookups, and a few style/readability nits.
| : us_(std::chrono::duration_cast<std::chrono::microseconds>(poll_delay)), type_(type), | ||
| key_size_(keysize), ipp_(ipp), | ||
| timer_(d.createTimer([this]() -> void { processRequests(); })) { | ||
| key_size_(keysize), ipp_(ipp), timer_(d.createTimer([this]() -> void { processRequests(); })), |
There was a problem hiding this comment.
you don't need the -> void
There was a problem hiding this comment.
Removed -> void from two places.
| void CryptoMbQueue::processRequests() { | ||
| if (type_ == KeyType::Rsa) { | ||
| // Increment correct queue size statistic. | ||
| stats_.getQueueSizeCounters()[request_queue_.size() - 1].get().inc(); |
There was a problem hiding this comment.
s/getQueueSizeCounters/queueSizeCounters/ per convention
There was a problem hiding this comment.
Removed after changing counters to histogram.
| tls_(ThreadLocal::TypedSlot<ThreadLocalData>::makeUnique(factory_context.threadLocal())) { | ||
| tls_(ThreadLocal::TypedSlot<ThreadLocalData>::makeUnique(factory_context.threadLocal())), | ||
| stats_(factory_context.scope(), CryptoMbQueue::MULTIBUFF_BATCH, "cryptomb", | ||
| "rsa_queue_size_") { |
There was a problem hiding this comment.
I assume this does not get called in response to requests, right? this happens at config-time?
If this does happen in response to requests then we should pre-symbolize the stat names and I can help you solve that without taking symbol-table locks. If this is called on config it's ok. But given it's not obvious how often this gets created, we should either comment on that assumption, or we should just go ahead and pre-symbolize all the names during config or (better yet) during startup.
There was a problem hiding this comment.
This happens at config-time, I added a comment about it.
| @@ -382,8 +407,11 @@ TEST(CryptoMbProviderTest, TestRSATimer) { | |||
| const BIGNUM *e, *n, *d; | |||
| RSA_get0_key(rsa, &n, &e, &d); | |||
| fakeIpp->setRsaKey(n, e, d); | |||
There was a problem hiding this comment.
this is pre-existing but the above 2 lines disturb me. They occur here and 4x in the prod code that I can see in this PR.
Can we have a helper API FakeIppCryptoImpl::setRsaKey(rsa); which captures the calls to RSA_get0_key and this->setRsaKey but initializes the 3 pointers to nullptr, and changes the 4 call-sites I can see in this PR and any others I can't see? :)
There was a problem hiding this comment.
Refactored tests in ops_test.cc and changed this.
| CryptoMbStats::CryptoMbStats(Stats::Scope& scope, uint32_t max_queue_size, | ||
| absl::string_view stats_prefix, | ||
| absl::string_view queue_size_stat_prefix) | ||
| : stat_name_pool_(scope.symbolTable()), stats_prefix_(stat_name_pool_.add(stats_prefix)) { |
There was a problem hiding this comment.
stats_prefix_ is not referenced after the constructor so you can drop the member variable and make this a local.
There was a problem hiding this comment.
This does not exist anymore after the histogram change.
| stats); | ||
|
|
||
| size_t in_len = 32; | ||
| uint8_t in[32] = {0x7f}; |
There was a problem hiding this comment.
there's a lot of repeated blocks of code in this test file. WDYT of factoring some of those out into methods/members of a test class for CryptoMbProviderTest, and shortening all these tests to hopefully make them more readable?
Then we can document some of the code that's mysterious like what this 0x7f is supposed to represent, or why in is 32 bytes long.
There was a problem hiding this comment.
Refactored tests in ops_test.cc and added comments.
|
/wait |
|
RE @ggreenway 's comment about histograms: I agree that would be a lot better, and that changes a few of my suggestions also. One thing to note is that the XDR histograms auto-decide buckets and I'm not sure if you need something more precise for this. I'm guessing auto-bucketed histograms would be fine. |
|
Thanks for the comments! @jmarantz @ggreenway I tried a histogram for this at one point, but the mentioned auto-decided buckets were confusing. Keeping each queue size as a separate counter shows the exact kind of queue sizes that come up. For example, the information on how frequently the biggest queue size comes up can be especially useful. However, I do agree that the histogram would be a better solution if it worked this way. |
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
|
There are two things happening with histograms: the internal storage auto-decides buckets (but is probably quite accurate). And the display from Can you clarify what the data looked like when you tried with a histogram? It may have just been that you need to configure the displayed buckets to get the results you need. /wait-any |
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
|
@ggreenway Thank you for the explanation! I changed the counters back to a histogram and the statsd solution worked as you explained. My initial confusion came from the way the histogram stats are displayed from the
The When this is in the config: Would there be an easy way to see individual queue sizes for this histogram, for example, from the |
I don't think there is currently. The base |
jmarantz
left a comment
There was a problem hiding this comment.
looks great; just a few nits. Will you follow-up with another PR to add detail to the /stats endpoint for histograms?
| ssl_private_key_result_t res_; | ||
|
|
||
| // A size for signing and decryption operation input chosen for tests. | ||
| static constexpr size_t IN_LEN = 32; |
There was a problem hiding this comment.
Const member variables follow member-variable naming convention, not macro convention, so call these in_len_, in_, etc.
| // Size of output in out_ from an operation. | ||
| size_t out_len_ = 0; | ||
|
|
||
| const std::string QUEUE_SIZE_HISTOGRAM_NAME = "cryptomb.rsa_queue_sizes"; |
Signed-off-by: Ville Pihlava <ville.pihlava@intel.com>
|
I can start looking into a follow-up PR on the |
jmarantz
left a comment
There was a problem hiding this comment.
Can you add an issue for the /stats histogram detail follow-up? I'll assign it to you.
I'll pass over to Greg for a senior maintainer pass.
|
The linked pull request #19586 is the follow-up to the discussion in this pull request. |
Add queue size statistics to CryptoMb private key provider. The queue size statistics show the amount of simultaneous crypto operations handled at the time of a SIMD (single instruction, multiple data) operation. The statistics consist of a histogram that indicates how often different queue sizes have been processed. Signed-off-by: Ville Pihlava <ville.pihlava@intel.com> Signed-off-by: Josh Perry <josh.perry@mx.com>
Commit Message:
Add queue size statistics to CryptoMb private key provider. The queue size statistics show the amount of simultaneous crypto operations handled at the time of a SIMD (single instruction, multiple data) operation. The statistics consist of a histogram that indicates how often different queue sizes have been processed.
Additional Description:
CryptoMb performance depends on the amount of simultaneous crypto operations processed. Statistics show how often different queue sizes are processed. The bigger the queue size, the better the throughput. The statistics help with debugging performance issues, finding good poll delay values, and show the distribution of different queue sizes.
Risk Level: Low
Testing: Unit testing, manual testing
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: CryptoMb private key provider requires Intel 3rd generation Xeon Scalable server processor for the AVX-512 IFMA instruction set.