I have a problem with performance, and i don't know where it comes from.
The gap between createLogoutURL and the first datastore query is huge... its between the following code passage:
loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));
...
ch.zhaw.ams.server.auth.user.User userAms = DatabaseHelper.findByParama(user.getEmail(), "emailAddress",
"String", ch.zhaw.ams.server.auth.user.User.class);
@Override
public GoogleLoginInfo login(String requestUri) {
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
GoogleLoginInfo loginInfo = new GoogleLoginInfo();
if (user != null) {
loginInfo.setLoggedIn(true);
loginInfo.setEmailAddress(user.getEmail());
loginInfo.setNickname(user.getNickname());
loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri));
loginInfo.setIsGoogleLogin(true);
ch.zhaw.ams.server.auth.user.User userAms = DatabaseHelper.findByParama(user.getEmail(), "emailAddress",
"String", ch.zhaw.ams.server.auth.user.User.class);
if (userAms != null) {
loginInfo.setFirstname(userAms.getFirstName());
loginInfo.setLastname(userAms.getLastName());
}
// Set Memcache
try {
SessionCache.setupCache(user.getEmail());
loginInfo.setIsCached(true);
} catch (CacheException e) {
// TODO Auto-generated catch block
e.printStackTrace();
loginInfo.setIsCached(false);
}
} else {
loginInfo.setLoggedIn(false);
loginInfo.setLoginUrl(userService.createLoginURL(requestUri));
}
return loginInfo;
}
Does anybody has an idea why its so slow?
On the plus side, appstats has narrowed it down to three lines for you:
You can probably fiddle around and try to figure out which line causes the delay. My best guess is that this is the first time you're loading the class ch.zhaw.ams.server.auth.user.User.class. This class might be causing other classes to load. The long delay you see might just be the class loading time.
You might be able to add a startup handler to load some of these classes, so it hopefully only appears rarely, but you'll see a lot of complaints about Java class loading time on GAE. It's not a problem that can be completely solved on GAE.