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

Slow type-checking in ChatMessageImageAttachment.swift #3428

Closed
pm-dev opened this issue Sep 24, 2024 · 2 comments
Closed

Slow type-checking in ChatMessageImageAttachment.swift #3428

pm-dev opened this issue Sep 24, 2024 · 2 comments
Labels
⚡ Performance An Issue or PR related to performance improvements 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK 🔜 Upcoming This issue is fixed in “develop” and will be available in the next release

Comments

@pm-dev
Copy link
Contributor

pm-dev commented Sep 24, 2024

What did you do?

Checked type-checking in our project and found a couple lines that took a while to type-check

xcodebuild clean build -project <YOUR PROJECT FILE NAME>.xcodeproj/ OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-expression-type-checking" | grep -Ei '^\d+\.\d+ms\t/.+$' | sort -r

What did you expect to happen?

I found that many of the most expensive expressions to typecheck were from this repo:
https://github.com/GetStream/stream-chat-swift/blob/develop/Sources/StreamChat/Models/Attachments/ChatMessageImageAttachment.swift#L128
and
https://github.com/GetStream/stream-chat-swift/blob/develop/Sources/StreamChat/Models/Attachments/ChatMessageImageAttachment.swift#L131
took 80ms and 60ms respectively on my laptop (2021 M1). If this was written without the ?? it would likely take 1-2ms.

https://github.com/GetStream/stream-chat-swift/blob/develop/Sources/StreamChatUI/StreamNuke/Internal/ImageRequestKeys.swift#L50
took 32ms

These were the most expensive expressions, but I encourage you to run with the -debug-time-expression-type-checking on the framework to see other locations that are taking a while

GetStream Environment

**GetStream Chat version: 4.63.0
**GetStream Chat frameworks: StreamChat
**iOS version: 18
**Swift version: 6
**Xcode version: 16
**Device: iOS Sim

Additional context

https://danielchasehooper.com/posts/why-swift-is-slow/

@testableapple testableapple added the ⚡ Performance An Issue or PR related to performance improvements label Sep 24, 2024
@testableapple
Copy link
Contributor

Hi @pm-dev, thank you very much for investigating this and opening the issue. I've added it to our backlog for further investigation. I can't give an ETA for now, but we'll share an update once we start working on it.

Best,
Alexey

@testableapple testableapple added the 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK label Sep 24, 2024
@nuno-vieira nuno-vieira added the 🔜 Upcoming This issue is fixed in “develop” and will be available in the next release label Oct 14, 2024
@nuno-vieira
Copy link
Member

This is now improved in the latest release 👍

Thank you for the report!

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 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK 🔜 Upcoming This issue is fixed in “develop” and will be available in the next release
Projects
None yet
Development

No branches or pull requests

3 participants