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

Use Cats backpressure to throttle writes (and conversions to HTTP requests) #1000

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

thorkildcognite
Copy link
Contributor

No description provided.

@thorkildcognite thorkildcognite requested a review from a team as a code owner December 11, 2024 16:10
@github-actions github-actions bot requested a review from silvavelosa December 11, 2024 16:10
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.33%. Comparing base (28a3425) to head (54431c0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1000   +/-   ##
=======================================
  Coverage   83.33%   83.33%           
=======================================
  Files          47       47           
  Lines        3156     3156           
  Branches      452      455    +3     
=======================================
  Hits         2630     2630           
  Misses        526      526           
Files with missing lines Coverage Δ
...main/scala/cognite/spark/v1/RawTableRelation.scala 94.87% <100.00%> (ø)

.unsafeRunSync()
Backpressure[IO](Backpressure.Strategy.Lossless, maxOutstandingRawInsertRequests)
.flatMap { backpressure =>
rows.grouped(batchSize).toVector.parTraverse_ { batch: Seq[Row] =>
Copy link
Contributor

Choose a reason for hiding this comment

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

compared to _.grouped.toSeq.grouped.foreach it will now create a vector of all batches, they will reference all Row items from iterator which potentially could be not a lot of mem, less than request bodies, more than constant mem

but compared to .grouped.toVector it is about the same apart from having semaphore

Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't look like there's a out-of-the box Seq.parTraverse_, or even better the one that would not take more items when semaphore is full, so for now we can try the .toVector.parTraverse_

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