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

Introduction of timeout in passes #5

Merged
merged 2 commits into from
Jul 30, 2024
Merged

Introduction of timeout in passes #5

merged 2 commits into from
Jul 30, 2024

Conversation

khemrajrathore
Copy link
Member

No description provided.

}
val duration =
if timeout == -1 then Duration.Inf else Duration(stopAt - currentTimeInMs, TimeUnit.MILLISECONDS)
Try(Await.result(future, duration)) match {
Copy link
Member

Choose a reason for hiding this comment

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

You have taken care of handling the overall timeout by honouring the remaining timeout at the thread level as well.

We need to use this place to introduce the thread-level timeout.

Copy link
Member

Choose a reason for hiding this comment

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

This is really not parallelising the processing.

stream.forEach creates one Future (at line no 272) for a given part and then the current main thread will wait for that future to finish (at line no 279). So In principle, you are processing the part sequentially. Which is as good as not using the Future

Copy link
Member

Choose a reason for hiding this comment

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

In order to implement the parallelism you need to iterate over all parts and start all the Futures and collect them in collection and apply timeout on Seqeunce of Futures.

Refer this code snippet as sample - https://github.com/Privado-Inc/privado-core/blob/main/src/main/scala/ai/privado/utility/ConcurrentProcessor.scala#L94-L103

@khemrajrathore khemrajrathore marked this pull request as ready for review July 26, 2024 13:04
@pandurangpatil pandurangpatil merged commit 41b751e into master Jul 30, 2024
1 check passed
@pandurangpatil pandurangpatil deleted the timeout branch July 30, 2024 11:50
tuxology pushed a commit that referenced this pull request Jul 30, 2024
tuxology pushed a commit that referenced this pull request Jul 30, 2024
tuxology pushed a commit that referenced this pull request Jul 30, 2024
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