Score:0

Time by "crypto_shash_digest"

mx flag

I am trying to calculate the time consumed to run SHA1 in the kernel level.

enter image description here

enter image description here

I had run the upper codes (inside a for loop) and the following was my result. It first showed about 30micro seconds and after about 300~400 times, it time suddenly dropped.

enter image description here

Here's my real question. I'm aware that the CPU can act differently time to time, I thought that the NUMA structure could or might effect these processes. But what I don't understand is that how could the time change with such difference?

Is there something that I'm missing here? And is there a more appropriate way to measure the time of cryptograpies.

fgrieu avatar
ng flag
Benchmarking is hard, and that's not limited to crypto. Unless there's a cryptographic-specific explanation (I doubt it), I think this is off-topic.
Maarten Bodewes avatar
in flag
This doesn't have enough info to trouble shoot, and it's not the specialty of our site to discuss kernel timings to be honest. Even if it were on topic, it would be better asked at a location that specializes in low level kernel routines.
Telemore avatar
mx flag
@MaartenBodewes Thank you for the kind comments, I understand.
Telemore avatar
mx flag
@fgrieu I tried to find more information or benchmarking tools...It all seemed impossible to directly use in the kernel, like you said. Thank you for your advice!
SAI Peregrinus avatar
si flag
I'd guess you're feeding it pretty predictable inputs. The CPU branch predictor, TLB, and other caches will adapt, so you'll see a speedup once all the needed data is in cache instead of in RAM. Probably some other similar effects.
Telemore avatar
mx flag
@SAIPeregrinus I did think about the cache effect or branch predictor, etc. But can a 'sudden' drop occur? Wouldn't a gradual decrease be more appropriate? I only studied the bachelor level of CS, so I might be totally wrong. (also thank you for your comment!)
SAI Peregrinus avatar
si flag
When something goes from uncached to cached, there's a very sudden speedup. Likewise for hits vs misses of a branch predictor. These effects are noticeable enough that they can sometimes be used to attack cryptosystems, look up "timing attacks".
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.