Nir Soffer has posted comments on this change. Change subject: utils: Add changehash function for change detection ......................................................................
Patch Set 1: (1 comment) http://gerrit.ovirt.org/#/c/33045/1//COMMIT_MSG Commit Message: Line 6: Line 7: utils: Add changehash function for change detection Line 8: Line 9: We use Python built-in hash to detect changes in vm state without sending Line 10: the state in each response. This function is not suitable for this > Could you explain why the lightweight hash() is not good enough for our use Using the built-in hash may be good enough, specially on 64 bit systems. The reason I suggest to use md5 instead is that this is the right tool for this job. Why md5 is favorable: - Output is stable, will not change between versions of Python, or even between runs. For example, when using the -R option, Python will randomize the hash on each run, invalidating engine hashes without change in vm state. - Easier to compose multiple hashes. For example, when we hash multiple hashes using a tuple (http://gerrit.ovirt.org/#/c/31701/13/vdsm/virt/vm.py), we are using different hash, is is good enough as the string hash? - Standard - Documented The built-in hash is much faster then md5, but we don't use it in a tight loop, and md5 should be fast enough to use when devices change on a vm. Computing the digest will probably be hidden by the cost of parsing and formatting the xml anyway. For example, on a minidell (9020): >>> timeit.timeit('hashlib.md5(s).hexdigest()', 'import hashlib; s = open("domain.xml").read()', number=1000) 0.007387876510620117 Line 11: usage. Now we use generic utils.changehash(), implemented using md5 Line 12: hexdigest. Line 13: Line 14: Change-Id: I2242a594383e2d2fe64e3a581f18b8ac662648b0 -- To view, visit http://gerrit.ovirt.org/33045 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I2242a594383e2d2fe64e3a581f18b8ac662648b0 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Nir Soffer <[email protected]> Gerrit-Reviewer: Adam Litke <[email protected]> Gerrit-Reviewer: Allon Mureinik <[email protected]> Gerrit-Reviewer: Dan Kenigsberg <[email protected]> Gerrit-Reviewer: Francesco Romani <[email protected]> Gerrit-Reviewer: Nir Soffer <[email protected]> Gerrit-Reviewer: Roy Golan <[email protected]> Gerrit-Reviewer: Vinzenz Feenstra <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
