-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relying on CustomStringConvertible for description of FlagSyncResult
Currently the SDK relies on performing flag sync up post-processing on the Main Thread, this in turn triggers LDClient.onFlagSyncComplete(result:) which has some os_log calls where the result is transformed into a String using String.init(describing:), this in turn uses Swift default implementation on stringifying objects which for large collections can be a big bottle-neck, we could easily identify instances where the Main Thread was running this piece of code for 200ms (we have around 280 flags in our project), causing hitches/hangs in our project. To address the issue I've conformed FlagSyncResult to CustomStringConvertible and provided a custom description, it mostly behaves the same with the exception for .flagCollection case in which we use JSONEncoder to stringify the list of flags. We've also transformed StoredItems typealias into a struct wrapping the dictionary in order to be able to provide a similar CustomStringConvertible conformance. With this change we could notice the execution time of LDClient.onFlagSyncComplete(result:) has dropped to levels between 30-40% of the original execution time.
- Loading branch information
Showing
6 changed files
with
88 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters