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

Move the auth_event table out of AuthS3 #1528

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hallamoore
Copy link
Contributor

Fixes #1525

This prevents the auth_event table from being loaded on every request.
The table_event getter in web2py tries looking for the table in db,
so I also had to override that getter on the AuthS3 class to look in
s3db instead.

Fixes sahana#1525

This prevents the `auth_event` table from being loaded on every request.
The `table_event` getter in web2py tries looking for the table in `db`,
so I also had to override that getter on the AuthS3 class to look in
`s3db` instead.
Comment on lines -460 to -461
migrate = migrate,
fake_migrate=fake_migrate,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't include these when copying it over since these options aren't passed into the model function. I think that's okay?

Copy link
Member

@nursix nursix left a comment

Choose a reason for hiding this comment

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

This change has no actual effect performance-wise - in production mode, with lazy tables, the table will anyway only ever be instantiated if actually accessed. It's not being loaded on every request, no.

So, it's optimizing a developer setup - but in the most developer-unfriendly way, by deviating from the super-class at the expense of introducing a workaround to make it even possible. IMHO this turns a good intention into a bad idea.

I would therefore say no to the entire motion here, i.e. drop it.

@flavour
Copy link
Member

flavour commented Dec 5, 2019

I would prefer to keep it personally...the performance advantage outweighs the extra subclass over-ride.
@nursix : Do you really want to veto this?

@nursix
Copy link
Member

nursix commented Dec 5, 2019

Yes, I would "veto" it - if there were anything like a veto ;)

Like I said: there is no measurable performance advantage - not in the developer setup, and even less in production mode for aforementioned reasons. The hack to make it work with web2py internals is confusing, and we shouldn't really mess with that - otherwise it could happen that we need compat-hacks for different web2py versions in the future...complications over complications.

But then again, there is no "veto" here - just a strong opinion based on long-term experience with web2py and Eden optimization. In my eyes, this goes overboard here for nothing.

If you have real evidence that there is a significant performance advantage, I might change my mind - but I for one couldn't find any.

@nursix
Copy link
Member

nursix commented Dec 5, 2019

@hallamoore : As you can see, #1525 isn't undisputed. I should have posted my concerns there already, but missed the opportunity as I got distracted by other things.

My main concern here is that we move the definition of a web2py framework entity entirely out of the subclass. Web2py have made structural changes to this API in the past, and when they would do so again in the future, we may be forced to introduce compatibility workarounds in order to support multiple versions (or otherwise force deployments to upgrade web2py, which isn't nice). I've had to do such compat workarounds in the past, and they are messy, and not exactly helpful with performance.

However, I agree that running the table definition for every request is unnecessary - although I still doubt the relevance of the performance impact it has, it's more that I agree based on the principle of laziness, i.e. don't do things unless you must.

If you have a suggestion how to resolve the dispute, that would be very welcome. If not, then maybe you have an opinion or arguments towards either side? Compelling evidence that the performance gain is worth the risk of future complications?

The minimum change that I would request here is this, though:

  1. Do not remove the table definition in AuthS3.define_tables, but comment it out, with an explanation where it has been moved and why
  2. Add a docstring to the AuthS3.table_event getter that explains what it is for and why it has been overridden

This helps us to remember if we need to adapt to future web2py changes, which could be years away, and we're senile and forgetful ;) so need to have such traces in the code.

@flavour
Copy link
Member

flavour commented Dec 5, 2019

My main concern here is that we move the definition of a web2py framework entity entirely out of the subclass.

The problem with anything like just defining the table in the getter is that then we need to handle table migrations separately...having this in s3db means everything just works smoothly

Web2py have made structural changes to this API in the past, and when they would do so again in the future, we may be forced to introduce compatibility workarounds in order to support multiple versions

My sense is that we're already at a point where upgrading to the latest Auth is non-trivial (& I'd like to do it at some point for 2-factor support)...I see this as very unlikely to be a big straw causing significant issues.

If you have a suggestion how to resolve the dispute, that would be very welcome. If not, then maybe you have an opinion or arguments towards either side?

Yup, thoughts/suggestions welcomed :)

@hallamoore
Copy link
Contributor Author

The override does feel a little developer unfriendly to me, but I've found web2py to be developer unfriendly as a whole so far. 😞 Extremely hard to follow unless you just know-how-it-works™️

The fact that this doesn't have any effect on prod makes me lean towards dropping it, but I don't have much perspective on how much developer pain is caused by this.

@nursix
Copy link
Member

nursix commented Dec 10, 2019

Given that you have both alternatives available, I think you can test how much of a "pain" is caused by having this model in AuthS3.define_tables vs. s3db: if you compare the average response times in each variant of a developer instance with debug/migrate on.

If that gives a significant advantage for the s3db-variant, then you have the necessary evidence that this change indeed improves something.

@nursix
Copy link
Member

nursix commented Dec 10, 2019

And I would really prefer to have this modification justified/backed by some evidence.

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.

Optimise by not loading auth_event every request
3 participants