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

Performance optimizations #9

Merged
merged 9 commits into from
Oct 20, 2014
Merged

Performance optimizations #9

merged 9 commits into from
Oct 20, 2014

Conversation

splattael
Copy link
Contributor

This PR tries to reduce method calls and object allocations.

See https://gist.github.com/splattael/5404417 for some benchmarks.

@rud
Copy link
Contributor

rud commented Nov 12, 2012

Any chance of before/after performance numbers?

@splattael
Copy link
Contributor Author

I've added some benchmarks and did further optimizations.
See PR description.

@splattael
Copy link
Contributor Author

I've redone my previous changes to match current state of lograge.

Currently, I see an overall performance increase of ~60%.
See benchmark: https://gist.github.com/splattael/5404417

@splattael splattael changed the title Minor refactoring. Performance optimizations Aug 7, 2014
@benlovell
Copy link
Collaborator

@splattael I'm gonna give this a good look over at the weekend and get it merged. Hold tight.

@splattael
Copy link
Contributor Author

@benlovell Thank you!

I know, this PR got huge over time. I happily slim it down if you think I'm refactoring too much here.
Just ping me if you want me to rebase or squash commits :)

@benlovell
Copy link
Collaborator

Hey @splattael, sorry for the delay. I've had a look over these changes and while they look good in principal - a good portion of the code has moved on since this was first proposed (unsurprisingly, of course.)

If you're happy to rebase and deal with anything that surfaces, I'll be happy to get this landed in master. Thanks ❤️

@splattael
Copy link
Contributor Author

@benlovell I've redone my optmizations on current master.

The results from benchmark after each commit starting with master:

Commit ips
a1a15a7 28046.09
0f31064 30187.33
44c26fa 30034.65
63f61f7 32891.11
caf7ffe 43526.63
4f093d5 44938.13
27083c0 44999.33
481301e 45808.29

(ips = instructions per second)

Note, I had to work around Rubocop in some cases (e.g. splattael@63f61f7#diff-d3a7c7717409a1c1353805f9579b980bR88)

Feedback is welcome :neckbeard:

@pxlpnk
Copy link
Collaborator

pxlpnk commented Oct 15, 2014

Where did you have to work around rubocop and why?

exception, message = payload[:exception]
{ status: 500, error: "#{exception}:#{message}" }
def extract_status(data, payload)
if (status = payload[:status])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of assignments within the if conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, alternatives seem to be "uglier" here.

@pxlpnk
Copy link
Collaborator

pxlpnk commented Oct 15, 2014

I like it, impressive performance improvement! 👍

location = Thread.current[:lograge_location]
return unless location
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pxlpnk I had to work around rubocop here. I'd use a simple assignment within condition again.

@pxlpnk
Copy link
Collaborator

pxlpnk commented Oct 16, 2014

This broke the tests.

@splattael
Copy link
Contributor Author

@pxlpnk Thanks for the heads-up! Fixed.
Note to myself: Do not submit patches in the morning. From bed. Via iPad. Without glasses :rage4:

@pxlpnk
Copy link
Collaborator

pxlpnk commented Oct 16, 2014

👍 a classic 😴 commit

@benlovell
Copy link
Collaborator

@splattael this is looking awesome. If you update the changelog I'll get this merged. Thanks! 😍

@splattael
Copy link
Contributor Author

@benlovell I've added an entry to the changelog.

@benlovell
Copy link
Collaborator

🌈 thanks!

benlovell pushed a commit that referenced this pull request Oct 20, 2014
@benlovell benlovell merged commit 7ff5b68 into roidrage:master Oct 20, 2014
@splattael
Copy link
Contributor Author

@benlovell Thanks for merging 💚

@rud
Copy link
Contributor

rud commented Oct 20, 2014

Persistence ftw 👍

splattael added a commit to splattael/lograge that referenced this pull request Feb 22, 2020
Avoid object creation (e.g. Hash) as much as possible by passing `data`.

Heavily inspired by roidrage#9
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

4 participants