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.
  • Loading branch information
jglick committed Jan 15, 2013
1 parent 1ecafe8 commit c757e65
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -58,6 +58,9 @@
<li class=bug>
Reduced size of memory leak in render-on-demand functionality used e.g. in configuration pages.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16341">issue 16341</a>)
<li class=bug>
Improving responsiveness of <b>People</b> page when using Gravatar plugin.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-16342">issue 16342</a>)
<li class=bug>
Improved logging and error output from SSHD in Jenkins.
</ul>
Expand Down
23 changes: 16 additions & 7 deletions core/src/main/java/hudson/model/View.java
Expand Up @@ -578,6 +578,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 @@ -779,12 +782,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 @@ -809,8 +816,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 @@ -826,7 +835,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 c757e65

Please sign in to comment.