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
Replace Time.parse with Time.iso8601 #1408
Conversation
@colinsurprenant sorry to chase you but to be sure that #1405 good work is complete maybe this PR proposal would help as well in your new Logstash::Timestamp for non-jruby https://github.com/colinsurprenant/logstash/blob/feature/faster_json/lib/logstash/timestamp.rb#L69 Now that you added cool specs, it should be easy to decide :) |
thanks for the heads up @wiibaa and thanks for the suggestion and benchmarks @dwbutler ! curious, are you actually running LS on MRI? there's JRuby dependant stuff like So, I have a branch here where I did a first quick pass for MRI compatibility, for Event#sprintf I simply used So the problem is essentially to either document the format syntax difference if using MRI or JRuby. Since by default everyone will be running under JRuby, I'm not sure its pertinent to potentially confuse users with such details in the doc (also note that most LS users don't even know JRuby is running under the hood). We threw the idea of maybe writing a Joda to strftime format converter. Not sure about that. So bottom lime, very few users will be running LS on MRI. On the other hand, I think its important to make sure LS does run on MRI as much as possible. What do you guys think? |
forgot to mention, I will not apply this suggestion on #1405 but in my MRI branch which has not been PR'ed yet - but I can push the branch if you guys want to play with it, or I could also create a "early" WIP PR. Let me know. |
@colinsurprenant There is actually a whole ecosystem of Ruby gems using the I noticed that if you pass a string timestamp to the
It's good to maintain cross-Ruby compatibility, but I get the impression that logstash is heading more towards deeper dependency on Java for performance reasons. In any case, |
@dwbutler good point about logstash-event. haven't really paid much attention to it, but will definitely put that on the roadmap. We'll see what makes more sense performance & maintainability wise. Again, we do want to maintain cross-Ruby compatibility, but as you noted, we will rely more on Java for performance reasons, so some features might not be available in non-JRuby environments, unless we also provide, or someone contributes, and alternate implementation. We'll try to make Java specific implementations as modular as possible to facilitate alternate implementations. |
Regarding time parsing ,I did these tests a long time ago:
|
@jordansissel I did find your benchmarks during my journey into the logstash code. =) The problem with that benchmark is that it's comparing apples to oranges. |
@dwbutler about your gist: I added a note for using |
Thanks Colin, I didn't know about |
@colinsurprenant if I'm not wrong @jordansissel time parsing benchmark was in the context of the date filter where it is required to parse "anything" but now that Event internal timestamp is more safe-guarded to be ISO8601 or be modified only through the date filter, the proposed change would still help, no? Also please have a look to jruby 1.7.12 new release, in particular for jruby/jruby#1319 if I understand correctly it could be a great benefit to long-running logstash instances |
@wiibaa I will integrate this into my MRI branch shortly. Also, we will definitely update to 1.7.12 but possibly not in 1.4.2. |
Can one of the admins verify this patch? |
f86287d
to
a536eef
Compare
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'. |
I signed the CLA. Not sure if/when the automated check will pick that up. |
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run; then say 'jenkins, test it'. |
Sadly we are moving away from a MRI implementation, so I think we can close this PR. :( |
I noticed that the
LogStash::Event
constructor callsLogStash::Time.parse_iso8601
. In MRI, this callsTime.parse
. The comment says it all: "Warning, ruby's Time.parse is really terrible and slow." Luckily, Ruby has an ISO8601 parsing method built into the standard library:Time.iso8601
.I ran the event RSpec benchmarks in MRI Ruby 2.1.2 and here are the results:
Before:
event @timestamp parse rate: 30851/sec, elapsed: 32.413648s
After:
event @timestamp parse rate: 71543/sec, elapsed: 13.977632s
So the rate more than doubled.
I also created a Gist benchmarking
Time.parse
vsTime.iso8601
in MRI and JRuby, vs the Joda implementation in JRuby.