New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Hamster::Set in checksummer for speed #887

Merged
merged 1 commit into from Jul 1, 2016

Conversation

Projects
None yet
1 participant
@ddfreyne
Member

ddfreyne commented Jul 1, 2016

Using Ruby’s Set in an immutable way is slow. Hamster::Set, from Hamster, is significantly faster.

Example: 1138s → 50s

Fixes #864.

digest.update(obj.class.to_s)
if visited.include?(obj)
digest.update('<recur>')
else
digest.update('<')
behavior_for(obj).update(obj, digest) { |o| update(o, digest, visited + [obj]) }
behavior_for(obj).update(obj, digest) { |o| update(o, digest, visited.add(obj)) }

This comment has been minimized.

@ddfreyne

ddfreyne Jul 1, 2016

Member

I could’ve left it that way, but #add is a nicer API, and it’s likely faster as well.

@ddfreyne

ddfreyne Jul 1, 2016

Member

I could’ve left it that way, but #add is a nicer API, and it’s likely faster as well.

@ddfreyne ddfreyne merged commit b2d0fb8 into release-4.2.x Jul 1, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ddfreyne ddfreyne deleted the hamster-set-in-checksummer branch Jul 1, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment