Skip to content

Commit

Permalink
[JENKINS-16342] Improving responsiveness of asynchPeople when Gravata…
Browse files Browse the repository at this point in the history
…r plugin is in use.

This change does not necessarily improve total performance, since the avatar is still computed.
But (1) the computation is correctly done in the work thread, not in the HTTP response thread;
(2) the computation is done just once for a given User, which could reduce load when many AJAX checks are done.(cherry picked from commit c757e65)

Conflicts:
	changelog.html
  • Loading branch information
jglick authored and vjuranek committed Jan 25, 2013
1 parent 7bc441d commit bd03abb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion changelog.html
Expand Up @@ -66,7 +66,8 @@
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-6604">issue 6604</a>)
<li class=bug>
Improving responsiveness of <b>People</b> page.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16397">issue 16397</a>)
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16342">issue 16342</a>,
<a href="https://issues.jenkins-ci.org/browse/JENKINS-16397">issue 16397</a>)
<li class=bug>
JNLP slave index page failed to explain how to pass <code>-jnlpCredentials</code>.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16273">issue 16273</a>)
Expand Down
23 changes: 16 additions & 7 deletions core/src/main/java/hudson/model/View.java
Expand Up @@ -585,6 +585,9 @@ public static final class UserInfo implements Comparable<UserInfo> {
*/
private AbstractProject project;

/** @see UserAvatarResolver */
String avatar;

UserInfo(User user, AbstractProject p, Calendar lastChange) {
this.user = user;
this.project = p;
Expand Down Expand Up @@ -786,12 +789,16 @@ public AsynchPeople(View parent) {
}
for (ChangeLogSet.Entry entry : build.getChangeSet()) {
User user = entry.getAuthor();
synchronized (this) {
UserInfo info = users.get(user);
if (info == null) {
users.put(user, new UserInfo(user, p, build.getTimestamp()));
UserInfo info = users.get(user);
if (info == null) {
UserInfo userInfo = new UserInfo(user, p, build.getTimestamp());
userInfo.avatar = UserAvatarResolver.resolve(user, iconSize);
synchronized (this) {
users.put(user, userInfo);
modified.add(user);
} else if (info.getLastChange().before(build.getTimestamp())) {
}
} else if (info.getLastChange().before(build.getTimestamp())) {
synchronized (this) {
info.project = p;
info.lastChange = build.getTimestamp();
modified.add(user);
Expand All @@ -816,8 +823,10 @@ public AsynchPeople(View parent) {
continue;
}
if (!users.containsKey(u)) {
UserInfo userInfo = new UserInfo(u, null, null);
userInfo.avatar = UserAvatarResolver.resolve(u, iconSize);
synchronized (this) {
users.put(u, new UserInfo(u, null, null));
users.put(u, userInfo);
modified.add(u);
}
}
Expand All @@ -833,7 +842,7 @@ public AsynchPeople(View parent) {
accumulate("id", u.getId()).
accumulate("fullName", u.getFullName()).
accumulate("url", u.getUrl()).
accumulate("avatar", UserAvatarResolver.resolve(u, iconSize)).
accumulate("avatar", i.avatar).
accumulate("timeSortKey", i.getTimeSortKey()).
accumulate("lastChangeTimeString", i.getLastChangeTimeString());
AbstractProject<?,?> p = i.getProject();
Expand Down

0 comments on commit bd03abb

Please sign in to comment.