-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add centralized rate limiter #305
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
base: master
Are you sure you want to change the base?
Conversation
| # Leaving one core for operating system and other background processes | ||
| num_processes = num_spark_driver_cores - 1 | ||
|
|
||
| if table.num_rows < num_processes: | ||
| num_processes = table.num_rows | ||
|
|
||
| # Input table is split into smaller chunks and processed in parallel | ||
| chunks = self.split_table(num_processes, table) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you intentionally deleting the comments here? There are some comment deletions throughout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't intentional. I ran the black and ruff formatting which probably did that. Added them back.
sdk/python/feast/rate_limiter.py
Outdated
| backoff = 0.005 # initial minimal sleep | ||
| while not self.acquire(): | ||
| # Compute estimated sleep until oldest timestamp exits window. | ||
| # We use the current index position as the next candidate slot. | ||
| now = time.time() | ||
| with self._lock: | ||
| oldest_ts = self.timestamps[self.index] | ||
| remaining = oldest_ts + self.period - now | ||
| if remaining <= 0: | ||
| continue | ||
| # Sleep the smaller of remaining and a capped value to re-check frequently. | ||
| time.sleep(min(remaining, 0.05)) | ||
| # Optional exponential backoff (bounded) if still not free. | ||
| backoff = min(backoff * 2, 0.05) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like backoff is actually used anywhere, it's only recalculated. Is this meant to be part of the minimum sleep instead of the hardcoded 0.05?
| entities_to_keep: Sequence[Entity], | ||
| partial: bool, | ||
| ): | ||
| # Call update only if there is an online store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you recomment this as well.
piket
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
# Conflicts: # sdk/python/feast/infra/passthrough_provider.py
This PR is to create a more generic solution for write rate limiting that can be utilized by all online stores.