Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace shared current user observer used for reading privacy settings #3502

Merged
merged 7 commits into from
Nov 21, 2024

Conversation

laevandus
Copy link
Contributor

@laevandus laevandus commented Nov 20, 2024

🔗 Issue Links

Part of IOS-558

🎯 Goal

Remove current user controller since it takes unnecessary CPU time when reacting to DB changes

📝 Summary

  • Replace internal current user controller with just reading the data directly

🛠 Implementation

We had a perf issue some time ago where we used to create the ChatCurrentUserController every single time when checking for typing state (on each key press). Then we started to use a shared instance for that. Solved the issue, but there is one downside, reacting to current user changes can get expensive (e.g. current user has many muted channels which triggers recreating channel objects when updating the immutable CurrentChatUser type). Instead all of this, we should just read the data we need and skip controllers.

🧪 Manual Testing Notes

Try typing events, if disabled, should not appear, otherwise appear.

☑️ Contributor Checklist

  • I have signed the Stream CLA (required)
  • This change should be manually QAed
  • Changelog is updated with client-facing changes
  • Changelog is updated with new localization keys
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (docusaurus, tutorial, CMS)

Constant observing can take time if the current user model has a lot of data attached to it
@laevandus laevandus added 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK ⚡ Performance An Issue or PR related to performance improvements labels Nov 20, 2024
@laevandus laevandus requested a review from a team as a code owner November 20, 2024 11:10
@Stream-SDK-Bot
Copy link
Collaborator

SDK Size

title develop branch diff status
StreamChat 7.02 MB 7.02 MB 0 KB 🟢
StreamChatUI 4.96 MB 4.96 MB 0 KB 🟢

@Stream-SDK-Bot
Copy link
Collaborator

SDK Performance

target metric benchmark branch performance status
MessageList Hitches total duration 10 ms 3.34 ms 66.6% 🔼 🟢
Duration 2.6 s 2.55 s 1.92% 🔼 🟢
Hitch time ratio 4 ms per s 1.31 ms per s 67.25% 🔼 🟢
Frame rate 75 fps 78.22 fps 4.29% 🔼 🟢
Number of hitches 1 0.4 60.0% 🔼 🟢

@Stream-SDK-Bot
Copy link
Collaborator

Stream-SDK-Bot commented Nov 20, 2024

SDK Size

title develop branch diff status
StreamChat 7.06 MB 7.06 MB +1 KB 🟢
StreamChatUI 4.96 MB 4.96 MB 0 KB 🟢

Copy link
Member

@nuno-vieira nuno-vieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ✅ It complicates a bit the code, but for now there's no alternative 👍

@laevandus laevandus added the 🤞 Ready For QA A PR that is Ready for QA label Nov 21, 2024
@laevandus laevandus added 🟢 QAed A PR that was QAed and removed 🤞 Ready For QA A PR that is Ready for QA labels Nov 21, 2024
@laevandus
Copy link
Contributor Author

QAed with @testableapple

@laevandus laevandus merged commit 98745b0 into develop Nov 21, 2024
6 of 12 checks passed
@laevandus laevandus deleted the perf/current-user-observing branch November 21, 2024 10:54
@Stream-SDK-Bot Stream-SDK-Bot mentioned this pull request Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ Performance An Issue or PR related to performance improvements 🟢 QAed A PR that was QAed 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants