Conversation
~22% fewer allocations (161 -> 125) ~14% fewer bytes used (9,936 -> 8,496) +18.7% iteration speed (23,114 ips -> 27,438 ips, 43.3μs -> 36.5μs per render) Using benchmarks/view_benchmark.rb on Ruby 4 (on an M1 Pro)
Member
|
Thanks for looking into this stuff, @cllns! My question is whether we might actually be able to solve this at a Dry Configurable level, rather than create a workaround for it here? We use Dry Configurable in many other places, so a solve there once would benefit us more. |
821a86e to
4c064ed
Compare
Member
Author
|
@timriley I was already working on it :) Just had to figure out the right API. See: dry-rb/dry-configurable#167 and updated changes here. I made a few tiny refactors to move things into private visibility. There's more I want to do, but I'll do that as a follow-on, so this PR doesn't get too complicated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
~28% fewer allocations (138 -> 99) per render
~18% fewer bytes used (8,739 -> 7,160) per render
+36.8% iteration speed (30,891 ips -> 42,266 ips, 32.4μs -> 23.7μs per render)
(Updated these numbers. The early improvements weren't as high but I closed some apps 😇 and these seem to be consistent)
Using benchmarks/view_benchmark.rb on Ruby 4 (on an M1 Pro).
I originally had this with a class-level
self.cached_configwhich isn't necessary so I removed it. This means each instantiation of a view has to computecached_configfor itself, adding some overhead. Since we've built this library based on the assumption that a single View will be re-used (rather than created new each time it's used), I think that's fine. Open to other perspectives though!Another option is using
reader: truefor all of the settings. I experimented with this too, but it's not as clean, because the settings are set on theViewclass rather than the config, soview_classhas to be passed around everywhere, which hides the intent of sending just config settings around. It's got basically the same performance as this approach though.