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

Caching routes #58

Merged
merged 7 commits into from
Sep 14, 2013
Merged

Caching routes #58

merged 7 commits into from
Sep 14, 2013

Conversation

csokol
Copy link
Contributor

@csokol csokol commented Sep 11, 2013

No description provided.

@lucascs
Copy link
Member

lucascs commented Sep 11, 2013

Is it really a performance issue?

@csokol
Copy link
Contributor Author

csokol commented Sep 11, 2013

It was one of the top classes spending time when we ran jprofiler in our project.

When the project has many routes and a lot of linkTo calls in the view, this might spend some time.

After this improvement, the router disappeared from jprofiler report and we beleive that improved about 5% in our response time (according to ab). It's not much, but is something, isn't?

@lucascs
Copy link
Member

lucascs commented Sep 11, 2013

We could compute this map on the initialisation, when registering the routes. What do you think?

controllerType = type;
this.method = method;
}

Copy link
Member

Choose a reason for hiding this comment

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

Hashcode and equals methods are too long. What you think to use Guava Objects or java.lang.Objects to compute hashCode and equals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I think that's fair, since it's a performance tuning :-)

The Class<?> type and Method method parameters are always the exact same reference? (given the same class and method...)?

Copy link
Member

Choose a reason for hiding this comment

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

@csokol, java.lang.Objects have methods to compute hashCode similar with Eclipse generated. Java.util.Objects is a utility class, not lava.lang.Object (sorry for not explaining properly).

@csokol
Copy link
Contributor Author

csokol commented Sep 11, 2013

But we cannot dicover dynamic routes such as /users/{id}. How could we compute that map during initialisation?

@lucascs
Copy link
Member

lucascs commented Sep 11, 2013

Since it's a map of Invocation => Route, there are no dynamic parameters =)

@csokol
Copy link
Contributor Author

csokol commented Sep 12, 2013

Duh. Of course, sorry :-)

I guess all I have to do is inject all controllers and implement
a @PostConstruct method to create the mappings, right?

Chico Sokol

On Wed, Sep 11, 2013 at 8:58 PM, Lucas Cavalcanti
notifications@gitpro.ttaallkk.topwrote:

Since it's a map of Invocation => Route, there are no dynamic parameters =)


Reply to this email directly or view it on GitHubhttps://github.com//pull/58#issuecomment-24285707
.


@Path("/myPath/{param}")
public void pathWithParam(String param) {
}
Copy link
Member

Choose a reason for hiding this comment

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

you're not using this method... throw it away :)

@csokol
Copy link
Contributor Author

csokol commented Sep 12, 2013

@lucascs, I've pushed some commits. I had to add a getter method to the Route interface, I couldn't find a better way to get the routes built and the controllers/methods during initialisation. Do you have I better solution?

It's working in musicjungle, but I left a test broken (the one with the proxy). If you don't have better idea I can work on fixing this test...

@csokol
Copy link
Contributor Author

csokol commented Sep 13, 2013

I've modified to call putIfAbstent and also fixed the test that was failing because of proxied methods. I had to modify the hashcode and equals methods of Invocation internal class...

@Turini
Copy link
Member

Turini commented Sep 14, 2013

🚢

csokol added a commit that referenced this pull request Sep 14, 2013
@csokol csokol merged commit 04321a7 into master Sep 14, 2013
@Turini Turini added this to the 4.0.0-beta-1 milestone Mar 6, 2014
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.

5 participants