discourse/app
Alan Guo Xiang Tan 24db6fbb73
PERF: Memoize topic level checks in PostGuardian (#19647)
When loading posts in a topic, the topic level guardian
checks are run multiple times even though all the posts belong to the
same topic. Profiling in production revealed that this accounted for a
significant amount of request time for a user that is not staff or anon.
Therefore, we're optimizing this by adding memoizing the topic level
calls in `PostGuardian`. Speficifally, the result of
`TopicGuardian#can_see_topic?` and `PostGuardian#can_create_post?`
method calls are memoized per topic.

Locally profiling shows a significant improvement for normal users
loading a topic with 100 posts.

Benchmark script command: `ruby script/bench.rb --unicorn --skip-bundle-assets --iterations 100`

Before:

```
topic user:
  50: 114
  75: 117
  90: 122
  99: 209
topic.json user:
  50: 67
  75: 69
  90: 72
  99: 162
```

After:

```
topic user:
  50: 101
  75: 104
  90: 107
  99: 184
topic.json user:
  50: 53
  75: 53
  90: 56
  99: 138
```
2023-01-03 09:00:42 +08:00
..
assets Build(deps): Bump eslint in /app/assets/javascripts (#19672) 2023-01-02 13:19:37 +01:00
controllers DEV: Improve performance of system test `sign_in` helper (#19579) 2022-12-22 16:03:27 +00:00
helpers FEATURE: Optionally allow a separate `s3_asset_cdn_url` to be specified (#19284) 2022-12-08 10:36:20 +00:00
jobs DEV: Skip push notifications for active online users (#19502) 2022-12-19 20:17:40 +00:00
mailers SECURITY: Filter tags in user notifications for visibility (#19239) 2022-11-29 10:35:41 -06:00
models PERF: Memoize topic level checks in PostGuardian (#19647) 2023-01-03 09:00:42 +08:00
serializers FIX: show status on mentions on just posted posts (#19639) 2022-12-29 14:34:59 +04:00
services DEV: Use WebPush fork for OpenSSL 3 compat (#19627) 2022-12-27 15:28:13 -03:00
views FIX: Broken images on subfolder installs (#19404) 2022-12-09 11:24:12 -07:00