performance - How much faster is the native implementation of the native cryptographic hashes on Windows than the .Net Managed version? -
i'm providing hashes sets of info in order fingerprint info , identify hash - core utilize case fast hashes sha1 , md5.
in .net, there alternative go native or managed implementations of of these hashes (the sha variants, anyway). i'm looking md5 managed implementation, , there doesn't appear 1 in .net framework, wondered if wrapped native csp faster anyway, , if should utilize content there no perf problems using it. top reply why there no managed md5 implementation in .net framework? indicates faster performance reason managed variant doesn't exist.
is true, , if so, how much faster native csp?
unfortunately, wrapped native csp md5 - md5cryptoserviceprovider
- slower pure managed implementation. obstinate viewpoint holds native code unequivocally faster managed code: in many cases opposite true. such case, @ to the lowest degree in head-to-head measurements.
using translated reference md5 implementation david anson, constructed quick performance test (source) aims measure big differences in performance between 2 implementations. while little info arrays difference negligible, expected, @ around 16kb native implementation starts show potentially important delay - on order of milliseconds. might not seem much, orders of magnitude slower pure managed implementation. difference maintained size of info beingness hashed increases, , @ largest tested info array - ~250mb - difference in cpu time 8.5 seconds. considering hash used fingerprint big files, delay become noticeable, against much larger delays i/o.
it's not abundantly clear delay comes from, since pure native test not performed (one dispense wrapping of csp , consumption in managed code), given identical shape of graphs on log scale, appear managed , native implementations have same intrinsic performance, native code performance "shifted" downwards in performance due cost of interop between native , managed code @ runtime. performance difference between wrapped native csps , pure managed implementations has been reproduced , documented other investigators.
in add-on answering question "how much faster native implementation" in particular case, hope evidence serves prompt more reflection , investigation when question of native vs. managed arises, breaking long-standing , pernicious reaction similar questions native code faster, , thus, somehow, better. managed code fast, in performance-sensitive domain of mass info hashing.
.net performance md5 native sha
No comments:
Post a Comment