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

Optimization to reduce facet "index" search on every request #97

Closed
wants to merge 2 commits into from

Conversation

i386
Copy link
Contributor

@i386 i386 commented Jan 1, 2017

Allows the dispatchers to run first and avoids searching the classpath for index files for each facet.

@i386
Copy link
Contributor Author

i386 commented Jan 1, 2017

PTAL @vivek

@@ -13,7 +13,7 @@ pipeline {
}
}

postBuild {
post {
Copy link
Contributor Author

@i386 i386 Jan 2, 2017

Choose a reason for hiding this comment

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

Unrelated change to make CI pass. Needs #93 to be merged.

@i386
Copy link
Contributor Author

i386 commented Jan 2, 2017

From what I can tell the test that is failing on CI is intermittent

@vivek
Copy link
Contributor

vivek commented Jan 4, 2017

Only concern I have is, if this change will bring slowdown to classic? Anyways, will wait for @kohsuke to comment. I wonder how it relates to #77, where for example blueocean can pretty much disable jelly path lookup for its rest apis.

@i386
Copy link
Contributor Author

i386 commented Jan 5, 2017

@vivek Oh now I know what #77 is all about. Requires a core bump for us though? :(

@vivek
Copy link
Contributor

vivek commented Jan 6, 2017

@i386 right, it needs core upgrade. Maybe we can put the code related to PR 77 feature in separate plugin that require upgraded core - this way everything else would continue working, only this parallel routing implementation plugin will need later core version. Something to investigate though.

@i386
Copy link
Contributor Author

i386 commented Jan 6, 2017

If only what was done in #77 was a plugable thing :(

@kohsuke
Copy link
Member

kohsuke commented Jan 9, 2017

I haven't look at this change yet, but we need to make sure this change doesn't have compatibility implications.

@i386
Copy link
Contributor Author

i386 commented Jan 9, 2017

@kohsuke what would be the best way to look at doing this?

@kohsuke
Copy link
Member

kohsuke commented Jan 14, 2017

I looked at this change more carefully.

For others, the context of this change is that the current order of lookup in trunk, in case there's no more token in URL path to process, is:

  1. Facets get to serve index views (such as index.jelly/.groovy/.html) if that's present
  2. doIndex method gets searchd

... so when routing a request to an object that has no view but doIndex, it results in unnecessary search of views before the routing finds the right target.

The proposed code change as of this comment solves this by swapping this order. Even though technically backward incompatible, this reordering is effectively compatible because no valid object would have had index view and doIndex method at the same time. This also makes the ordering consistent with xyz.jelly vs doXyz. The latter wins currently.

What this change fails to accomodate is that the code now pushes index view search so far down the priority list that now it's behind doDynamic. This would break a valid user code that defines the index view as well as doDynamic as the catch-all.

I think the additional change needed is to fold index view serving into a part of Dispatcher like everythng else. The same goes with HttpDeletable handling (which probably should be deprecated at this point given @DELETE annotation.)

This way, index view can be served at the exact right priority, and code becomes cleaner. In addition, for typical facet implementations like Jelly, the script search can be front-loaded entirely to improve dispatching performance in case a class that doesn't define an index view.

I'll make this follow up change and put it up as a new PR.

@i386
Copy link
Contributor Author

i386 commented Jan 14, 2017

Thanks mate I look forward to it

kohsuke added a commit that referenced this pull request Jan 15, 2017
The presence of index.html in a side file can be tested eagerly to avoid
checking it at runtime. Since this feature is rarely used, this results
in a performance gain.

See: #97
@kohsuke
Copy link
Member

kohsuke commented Jan 15, 2017

Overtaken by #101

@kohsuke kohsuke closed this Jan 15, 2017
jglick pushed a commit that referenced this pull request Jan 18, 2017
Currently the code performs index view lookup before doIndex handling.
This behaviour is inconsistent with the relative ordering between
xyz.jelly vs doXyz where the latter wins. This behaviour is considered
sensible because it'd allow programmatic check before a view is
rendered by using StaplerRequest.getView().

The code also has a performance improvement effect for those model
objects that do not define any index view but doIndex, by going straight
to doIndex without bothering to try index views. Objects that do define
index view without doIndex will perform the same, because the presence
of doIndex is tested during MetaClass.buildDispatchers(), and not during
dispatching requests.

See: #97
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.

3 participants