Project

General

Profile

Actions

Defect #35192

closed

Watchers pop up window appears after a long time

Added by Jean-René ROUET over 5 years ago. Updated 3 days ago.

Status:
Closed
Priority:
Normal
Category:
Issues
Target version:
Resolution:
Fixed
Affected version:

Description

Hi

patch #33329 introduces a performance issue

When you want to add a watcher to an issue in a project with many collaborators, the pop-up window take between 10 sec and 20 sec (according to the number of collaborators) to appear.
It's very disturbing because user has no graphical indication about that.

regards


Files


Related issues

Related to Redmine - Patch #33329: Improve watchers functionality to mark the users that are watching a non visible object and to not return watchers that cannot see the objectClosedGo MAEDAActions
Actions #1

Updated by Marius BĂLTEANU over 5 years ago

  • Assignee set to Marius BĂLTEANU
Actions #2

Updated by Marius BĂLTEANU over 5 years ago

  • Related to Patch #33329: Improve watchers functionality to mark the users that are watching a non visible object and to not return watchers that cannot see the object added
Actions #3

Updated by Marius BĂLTEANU over 5 years ago

How many members do you have on the project where you experience this issue? (rounded number).

In #33329, I've proposed two options (4 and 5) to avoid this performance issue, which one works better for you?

Actions #4

Updated by Jean-René ROUET over 5 years ago

Hi

when it took 10 seconds to pop up, there is 900 members.
when it took 25 seconds, there is 2500 members.
it's linear

I prefer the option 4

Actions #5

Updated by Simon Hori over 4 years ago

Hello Marius,

Thank you for the patch #33329 that is good improvement for sure.
But we do have the same perfomance problem with 1300+ users.

watchable_object.visible?(user)
is making at least two SQL queries per user.

I don't think we need all users names listed when the search query is blank. so I would like to request option 4.

As a test, I made this change and it reduced loading time from 4 sec to 0.2 sec.

-       scope = @project.principals.assignable_watchers
+       scope = @project.principals.assignable_watchers.limit(100)
Actions #6

Updated by Benoît Yegre about 4 years ago

Hello

We have the same problem that watchers pop up window appears after a long time.

Config :

Environment:
  Redmine version                4.2.8.stable
  Ruby version                   2.7.6-p219 (2022-04-12) [x86_64-linux]
  Rails version                  5.2.8.1
  Environment                    production
  Database adapter               PostgreSQL
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
SCM:
  Subversion                     1.14.1
  Mercurial                      5.6.1
  Bazaar                         3.1.0
  Git                            2.30.2
  Filesystem                     
Redmine plugins:
  redmine_openid_connect         0.9.4

We have 3 000 users and when we want add watchers for an issue, it takes a while to appear the watchers box (20 seconds).

Is there a solution ?
- like limiting watchers for a project ...

Thank you for your help.

Actions #7

Updated by Guillermo ML about 3 years ago

We have hit the same performance problems.
We have a project with 1125 members, it takes ~4s to show the windows and another ~3 to see the watcher added.
On projects with few users the action is almost immediate.

Our configuration

Actions #8

Updated by Dmitrijs Migunovs almost 2 years ago

5.1.3.stable - same issue. We have 242 users, and the Watchers pop-up takes about 5-10 seconds to open.

Member Load (32.1ms)  SELECT `members`.* FROM `members` INNER JOIN `projects` ON `projects`.`id` = `members`.`project_id` WHERE `members`.`user_id` = 274 AND `projects`.`status` != 9 AND `members`.`project_id` = 8 ORDER BY `members`.`id` ASC LIMIT 1
Role Load (32.1ms)  SELECT DISTINCT `roles`.* FROM `roles` INNER JOIN `member_roles` ON `roles`.`id` = `member_roles`.`role_id` WHERE `member_roles`.`member_id` = 5706
Actions #9

Updated by Takenori TAKAKI 3 months ago

Following the discussion here and the "option 4" idea in #33329, here is a patch that takes a "Load more" approach rather than a hard limit. It applies on current trunk.

A hard limit fixes the slowness but hides the members beyond it when no search term is entered. This patch shows the first 100 members and lets users load the rest via "Load more", so no one becomes unreachable. Search is unchanged (already limited to 100).

Actions #10

Updated by Takenori TAKAKI about 1 month ago

This is an update to the "Load more" patch posted above, based on further review.

Changes since the previous patch:
  • Fixed a possible edge case in the "Load more" click handling.
  • Minor cleanups (naming, wording).

No behavior change from what was described before: the dialog still shows the first 100 members and loads more on demand; search is unchanged.

Benchmark:

With ~4000 project members, opening the watcher dialog (development environment, initial list capped at 100):
  • Before: ~6.4s
  • After: ~0.15s

Screenshots:

Initial view: first 100 members, "Show more" trigger at the bottom.

After clicking "Show more": the list now goes past the previous 100-item cap, and the previously checked user is still checked.

Searching still caps at 100 results with no "Show more" trigger (unchanged from before).

Actions #11

Updated by Marius BĂLTEANU about 1 month ago

  • Target version set to 7.1.0
Actions #12

Updated by Katsuya HIDAKA about 1 month ago

The patch mentioned in #note-10 looks good to me.

I tested it with a project containing over 4,000 members and confirmed that it improves performance. I also verified that pagination works correctly on Chrome, Safari, and Firefox.

All tests pass as well.

Actions #13

Updated by Takenori TAKAKI 15 days ago

Unlike #44350, where I found the reported slowness was largely a Bullet-gem artifact (see #44350#note-18), this one is a real problem regardless of Bullet. With ~4000 members, opening the watcher dialog:

  • trunk, Bullet on (default): ~6.5-7.2s
  • trunk, Bullet off: ~6.0-6.5s — barely different, so Bullet isn't the cause here
  • trunk, Bullet on + watcher-dialog-load-more-v2.patch: ~0.16-0.30s
Actions #14

Updated by Marius BĂLTEANU 11 days ago

Thank you Takenori TAKAKI for working on this, and Katsuya HIDAKA for testing.

I've rework the solution and attached an updated version. It keeps the same "Show more" approach (the first 100 members, then the next pages on demand), with the following changes:
  • Pre-filters visible watchers in SQL before applying offset and limit, ensuring accurate page sizes and avoiding empty pages.
  • Pagination also works for searches: a broad search (e.g. a common first name) is no longer silently capped at 100 results, and it shows "Show more" like the initial list.
  • The search field and the pagination are handled by a new reusable Stimulus controller (searchable-selection), which replaces the legacy observeSearchfield inline script for this dialog:
    • debounced search, with in-flight requests cancelled using AbortController
    • "Show more" pagination with loading feedback
    • the checked users are kept when loading more users and when searching
  • Functional tests for pagination and search, and system tests for "Show more" and adding watchers from a later page.

The controller is generic, so it can later replace observeSearchfield in the other user selection dialogs (group users, project members). I'll add new issue and the patch after we finish this one.

Feedback and testing are welcome.

Actions #15

Updated by Takenori TAKAKI 10 days ago

Thanks for the new patch, Marius BĂLTEANU. Applies cleanly and looks solid — it also fixes search pagination, which my earlier "Load more" patch didn't handle.

Performance: measured in production environment, on a project with 4000 members (same scale as before): dialog load went from ~4.2s to ~120ms.

Tests: applying the #note-14 patch causes 2 test failures and 1 rubocop nit. Attaching a patch that fixes them — 0002-fix-test-failures-watchers-dialog-pagination.patch, apply it on top of the #note-14 patch:

  • test_new_with_multiple_objects_from_different_projects — updated the regex for the now-escaped & in the autocomplete URL.
  • test_add_watcher_with_show_more — moved user1/user2 out of the within block so they're in scope for the later assertion.
  • has_more = has_more || (...) → has_more ||= (...) (Style/SelfAssignment).
Actions #16

Updated by Katsuya HIDAKA 5 days ago

I've confirmed that the patches attached in #note-14 and #note-15 work as expected in Chrome, Safari, and Firefox and resolve this performance issue. Looks good to me.

Actions #17

Updated by Marius BĂLTEANU 3 days ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Thanks again for your work on this, both patches are now committed.

Actions

Also available in: Atom PDF