-
Notifications
You must be signed in to change notification settings - Fork 568
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 of WebMock::Util::Headers.normalize_headers
#1027
Comments
Optimizes the `WebMock::Util::Headers.normalize_headers` method to: * Create less objects * Avoid using Regexp where possible * Hoists constants More details can be found in the related issue, including performance benchmarks: bblimke#1027
Optimizes the `WebMock::Util::Headers.normalize_headers` method to: * Create less objects * Avoid using Regexp where possible * Hoists constants More details can be found in the related issue, including performance benchmarks: bblimke#1027
Opened a PR which addresses this: |
@baweaver are you running the conventional vite dev server, or transpiling production-like assets and using the vite "preview" server? If it's the former, I would think there might be an incredibly long daisy chain of necessary module fetches, which on http/1.1 (the default if you haven't set up local certs) could really slow down your capybara specs. The optimization and recommendation would be to generate assets and serve them via the vite "preview" server. If you're already using the preview server, I'd be super curious to continue chatting about what you find on the rails perf slack (handle: vanderhoop) or elsewhere. |
@vanderhoop we're using vite-rails which ends up running the conventional vite-dev server. I looked, and I'm not seeing an option for the preview server. I can file issues there about that. I think there's still value in improving the performance of this particular method in any event. If anyone reading this is looking for resources about Ruby & Memory, I've found How Ruby Uses Memory — SitePoint to be a great guide. It touches a bit on how object allocation can affect performance. |
@baweaver thank you for this great research and analysis. Awesome work! The PR is merged. |
While trying to sort out some Capybara speed issues we were running memory profiling and noticed that there was an exceptionally hot path in the
normalize_headers
method. We took a more detailed look at it and came up with this experiment to see what interesting information we could find on it:There are some important caveats and nuances to mention in this:
That said, this does represent a performance improvement in what can be a hot path in larger applications.
Looking for feedback and/or interest level in this type of change before I go pushing any PRs on it.
The text was updated successfully, but these errors were encountered: