Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

slow rollout of rust ML

laurenspriem113bff19a58f
diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
index 3d220a10d6..a4c29dea02 100644
--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
@@ -16,6 +16,8 @@ class FlagService {
static const int _commentsFlag = 1 << 1;
static const int _backupOptionsFlag = 1 << 2;
static const int _videoStreamingFlag = 1 << 3;
+ static const int _rustMlRolloutPercent = 10;
+ static const String _userIdKey = "user_id";
final SharedPreferences _prefs;
final Dio _enteDio;
@@ -106,9 +108,11 @@ class FlagService {
bool get enableMemoryShareLink => true;
- bool get useRustForML => internalUser;
+ bool get useRustForML =>
+ internalUser || _isInUserRollout(_rustMlRolloutPercent);
- bool get enableMLInBackground => internalUser;
+ bool get enableMLInBackground =>
+ internalUser || _isInUserRollout(_rustMlRolloutPercent);
bool get useRustForFaceThumbnails => true;
@@ -199,4 +203,15 @@ class FlagService {
bool _isServerFlagEnabled(int flagBit) =>
(flags.serverApiFlag & flagBit) != 0;
+
+ bool _isInUserRollout(int percent) {
+ final userId = _prefs.getInt(_userIdKey);
+ if (userId == null || userId <= 0 || percent <= 0) {
+ return false;
+ }
+ if (percent >= 100) {
+ return true;
+ }
+ return userId % 100 < percent;
+ }
}