Skip to content
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 SecureRandom if uuid4r is not available #51

Merged
merged 1 commit into from Feb 28, 2019
Merged

Use SecureRandom if uuid4r is not available #51

merged 1 commit into from Feb 28, 2019

Conversation

atrzaska
Copy link
Contributor

@atrzaska atrzaska commented Oct 1, 2018

Fixes: #50

Problem

Currently beetle uses UUID4R gem for generating message UUID.
UUID4R gem uses OSSP-UUID native library.
OSSP-UUID library is outdated (2008). It is also not included as package in many linux distributions.
Therefore many times developers are stuck installing this library by compiling from the source.

Proposal

Replace UUID4R gem with SecureRandom.

Speed benchmark

SecureRandom seems like a 4 times faster solution than UUID4R:

[4] pry(main)> Benchmark.bmbm(100) { |b| b.report('SecureRandom.uuid') { SecureRandom.uuid }; b.report('UUID4R::uuid(4)') { UUID4R::uuid(4) } }
Rehearsal ----------------------------------------------------------------------------------------------------------------------------------------
SecureRandom.uuid                                                                                      0.000037   0.000004   0.000041 (  0.000034)
UUID4R::uuid(4)                                                                                        0.000032   0.000112   0.000144 (  0.000144)
------------------------------------------------------------------------------------------------------------------------------- total: 0.000185sec

                                                                                                           user     system      total        real
SecureRandom.uuid                                                                                      0.000029   0.000003   0.000032 (  0.000027)
UUID4R::uuid(4)                                                                                        0.000030   0.000078   0.000108 (  0.000103)

@atrzaska
Copy link
Contributor Author

atrzaska commented Oct 1, 2018

@skaes PTAL

@atrzaska atrzaska changed the title Replace UUID4R.uuid(4) -> SecureRandom.uuid, remove ossp-uuid dependency Replace UUID4R.uuid(4) -> SecureRandom.uuid, remove OSSP-UUID native dependency Oct 1, 2018
@skaes
Copy link
Contributor

skaes commented Feb 28, 2019

I'm reluctant to merge this, because we have no information on the quality of randomness of SecureRandom vs UUID4r. Could be better, worse or just as good.

Also, in order to merge it, it must not include changes to lib/version.rb or the RELEASE notes.

@atrzaska
Copy link
Contributor Author

@skaes I reverted changes to lib/version, readme and changelog.
SecureRandom is faster and should be also very secure to use. It is also included in ruby so it is maintained, unlike ossp_uuid.

@skaes
Copy link
Contributor

skaes commented Feb 28, 2019

I still have my doubts. Can you please change the code to still allow the use of UUID4R if it is available?

Please follow this pattern: https://github.com/skaes/logjam_agent/blob/master/lib/logjam_agent.rb#L221-L230
but without the gsub.

Then we can try rolling this out incrementally.

And please make uuidr a development dependency.

@atrzaska
Copy link
Contributor Author

@skaes Addressed. Let me know if those changes look ok.

@atrzaska atrzaska changed the title Replace UUID4R.uuid(4) -> SecureRandom.uuid, remove OSSP-UUID native dependency Use SecureRandom if uuid4r is not available Feb 28, 2019
@skaes
Copy link
Contributor

skaes commented Feb 28, 2019

LGTM. Thx for the contribution.

@skaes skaes merged commit 6d4d972 into xing:master Feb 28, 2019
@atrzaska atrzaska deleted the remove_ossp_uuid branch February 28, 2019 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants