-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Perf: avoid dupes add fallback logic for coders #12188
Conversation
NOTE: please hold off on merging this until I fully test it and run it for a bit. Comments totally welcome :) |
} | ||
} | ||
column = @columns_hash[name] if @columns_hash | ||
column = self.class.column_types[name] unless column |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
column ||= self.class.column_types[name]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops :) will fix
I just run the discourse bench on this and got the following: Before
After
Its a noticeable improvement, brings Discourse home page only a smidgen slower than it was on rails 3 but the topic page is now much faster. For comparison, these are the numbers on Rails 3
|
I think this is good to merge, thoughts? |
@SamSaffron thanks! |
Perf: avoid dupes add fallback logic for coders
Perf: avoid dupes add fallback logic for coders
|
||
@attributes_cache = {} | ||
@column_types = self.class.column_types | ||
@column_types_override = fresh_object.instance_variable_get('@columns_types_override') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a typo on the instance var call here, I fixed that on master and 4-0, lets keep an eye on travis now ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, totally my bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I know why that happened ... columns_hash vs. column_types we should make that consistent at least.
column_types_hash and. column_types perhaps, maybe figure out a way of eliminating @columns_hash?
@tenderlove @SamSaffron I've been using 4-0-stable happily until this was merged, 918a148 is the first 'bad' commit which causes this issue:
There are four migrations that should have run but it gets to the end of the first one and fails to continue. Not sure why, I'll go back to using the ref before this started failing for now. Thanks! ❤️ |
@parndt is there any chance you can mail me details to a repro at sam.saffron@gmail.com It appears that
|
@SamSaffron here you go https://github.com/parndt/rails-pull-12188 Just clone, bundle, rake db:migrate, kaboom! |
@SamSaffron wow thanks for the quick turnaround |
@parndt make sure you are using latest 4-0-stable and protected_attributes master and you issue will be fixed. |
This had a pretty significant perf improvement, will run numbers tomorrow and add to the ticket, it changes semantics of @column_hash , nonetheless all the tests seem to pass.
It avoids fairly significant repetitive copies of columns in a table on each instance. If this is found to be safe its a strong candidate for backport into 4.0.