Skip to content

PIR: Add support for multiple profile queries in PirScan and PirOptOut #6413

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

landomen
Copy link
Contributor

@landomen landomen commented Jul 17, 2025

Task/Issue URL: https://app.asana.com/1/137249556945/project/1210594645151737/task/1210750227652612?focus=true

Description

Adds support for running the initial PIR scan and PIR opt-out scan on multiple stored profiles instead of the first stored profile. See the task for more details and a full tech spec.

Steps to test this PR

1 profile (current behavior)

  • Enter a new profile and trigger scan - scan runs for 1 profile
  • Go to opt-out scan and trigger it for any broker - scan runs for 1 profile

Multiple profiles (new behavior)

  • Clear data and trigger scan without any input - scan runs for 3 hardcoded profiles
  • Go to opt-out scan and trigger it for any broker - scan runs for all 3 profiles (assuming that the profiles were found for that broker)

UI changes

No UI Changes

@landomen landomen requested a review from karlenDimla July 17, 2025 13:58
@karlenDimla karlenDimla self-assigned this Jul 18, 2025
}.flatten()
}.filter { it.value.isNotEmpty() }

val stepsCount = profileBrokerStepsMap.values.maxOf { it.size }
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic seems incorrect. The thing that we want to do here is to use the total number of profile x broker x extractedProfile instances IF it’s lesser than the max limit. In this case, we are just taking the highest value.

@@ -101,16 +104,22 @@ class RealBrokerStepsParser @Inject constructor(
override suspend fun parseStep(
brokerName: String,
stepsJson: String,
profileQuery: ProfileQuery?,
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: We can just pass the profileQuery.Id here too.

}.filter { it.value.isNotEmpty() }

// Start each runner on the profile with the broker steps
profileBrokerStepsMap.entries.map { (profileQuery, brokerSteps) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Why entries.map and not forEach?

}
}.awaitAll()
// Start each runner on the profile with the broker steps
profileBrokerStepsMap.entries.map { (profileQuery, brokerSteps) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Same issue here, we are not utilizing the maximum limit of webviews. Consider if we have this map:

mapOf{
profileA, 4 extracted profiles
profileB, 1 extracted profiles
profileC, 15 extracted profiles
)

It will only use 4 webviews initially and then 1 and then 15. Ideally this could all have run 20 webviews all at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, there is a limitation to the runners that requires a profile query to be passed in along with the steps, which makes it a bit harder to implement an optimized solution. I will take some time (until Monday) to try to implement a more optimized solution that utilizes all available runners.

// Start each runner on a subset of the broker steps.
brokers.mapNotNull { broker ->
// Split all the broker steps into parts that can be executed in parallel
val brokerScanSteps = brokers.mapNotNull { broker ->
Copy link
Contributor

Choose a reason for hiding this comment

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

This works but could’ve be improved if we consider how many profile x broker combinations there would be and then divide that according to the limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants