You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "Abacn (via GitHub)" <gi...@apache.org> on 2024/03/20 21:37:54 UTC
[PR] Add warning when retrieving state cache inefficiency detected [beam]
Abacn opened a new pull request, #30696:
URL: https://github.com/apache/beam/pull/30696
**Please** add a meaningful description for your change here
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add warning when retrieving state cache inefficiency detected [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30696:
URL: https://github.com/apache/beam/pull/30696#issuecomment-2010905176
Assigning reviewers. If you would like to opt out of this review, comment `assign to next reviewer`:
R: @riteshghorse for label python.
Available commands:
- `stop reviewer notifications` - opt out of the automated review tooling
- `remind me after tests pass` - tag the comment author after tests pass
- `waiting on author` - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)
The PR bot will only process comments in the main thread (not review comments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add warning when retrieving state cache inefficiency detected [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #30696:
URL: https://github.com/apache/beam/pull/30696#discussion_r1534080187
##########
sdks/python/apache_beam/runners/worker/sdk_worker.py:
##########
@@ -1272,14 +1277,40 @@ def _lazy_iterator(
:return A generator which returns the next element if advanced.
"""
while True:
- data, continuation_token = (
- self._underlying.get_raw(state_key, continuation_token))
- input_stream = coder_impl.create_InputStream(data)
+ input_stream, continuation_token = self._get_raw(
+ state_key, continuation_token)
+
while input_stream.size() > 0:
yield coder.decode_from_stream(input_stream, True)
if not continuation_token:
break
+ def _get_raw(self, state_key, continuation_token):
+ """Call underlying get_raw with performance statistics and detection."""
+ start_time = time.time()
+
+ data, continuation_token = (
+ self._underlying.get_raw(state_key, continuation_token))
+
+ input_stream = coder_impl.create_InputStream(data)
+
+ self._retrieval_time += time.time() - start_time
+ self._get_raw_called += 1
+
+ if self._retrieval_time > self._warn_interval:
+ _LOGGER.warning(
+ f"Retrieving state {self._get_raw_called} times costed "
+ f"{self._retrieval_time:.0f} seconds. It may be due to insufficient "
+ "state cache size and/or frequent direct access of states.\n"
Review Comment:
phrased to more specific message.
There is a INFO worker log like "Creating state cache with size 26214400" for every harness started
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add warning when retrieving state cache inefficiency detected [beam]
Posted by "liferoad (via GitHub)" <gi...@apache.org>.
liferoad commented on code in PR #30696:
URL: https://github.com/apache/beam/pull/30696#discussion_r1532926148
##########
sdks/python/apache_beam/runners/worker/sdk_worker.py:
##########
@@ -1272,14 +1277,40 @@ def _lazy_iterator(
:return A generator which returns the next element if advanced.
"""
while True:
- data, continuation_token = (
- self._underlying.get_raw(state_key, continuation_token))
- input_stream = coder_impl.create_InputStream(data)
+ input_stream, continuation_token = self._get_raw(
+ state_key, continuation_token)
+
while input_stream.size() > 0:
yield coder.decode_from_stream(input_stream, True)
if not continuation_token:
break
+ def _get_raw(self, state_key, continuation_token):
+ """Call underlying get_raw with performance statistics and detection."""
+ start_time = time.time()
+
+ data, continuation_token = (
+ self._underlying.get_raw(state_key, continuation_token))
+
+ input_stream = coder_impl.create_InputStream(data)
+
+ self._retrieval_time += time.time() - start_time
+ self._get_raw_called += 1
+
+ if self._retrieval_time > self._warn_interval:
+ _LOGGER.warning(
+ f"Retrieving state {self._get_raw_called} times costed "
+ f"{self._retrieval_time:.0f} seconds. It may be due to insufficient "
+ "state cache size and/or frequent direct access of states.\n"
Review Comment:
possible to show the current cache size? and show the option to change it? basically make it more informative.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add warning when retrieving state cache inefficiency detected [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn merged PR #30696:
URL: https://github.com/apache/beam/pull/30696
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add warning when retrieving state cache inefficiency detected [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on PR #30696:
URL: https://github.com/apache/beam/pull/30696#issuecomment-2012735919
what it looks like now:

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add warning when retrieving state cache inefficiency detected [beam]
Posted by "riteshghorse (via GitHub)" <gi...@apache.org>.
riteshghorse commented on code in PR #30696:
URL: https://github.com/apache/beam/pull/30696#discussion_r1534029897
##########
sdks/python/apache_beam/runners/worker/sdk_worker.py:
##########
@@ -1272,14 +1277,40 @@ def _lazy_iterator(
:return A generator which returns the next element if advanced.
"""
while True:
- data, continuation_token = (
- self._underlying.get_raw(state_key, continuation_token))
- input_stream = coder_impl.create_InputStream(data)
+ input_stream, continuation_token = self._get_raw(
+ state_key, continuation_token)
+
while input_stream.size() > 0:
yield coder.decode_from_stream(input_stream, True)
if not continuation_token:
break
+ def _get_raw(self, state_key, continuation_token):
+ """Call underlying get_raw with performance statistics and detection."""
+ start_time = time.time()
+
+ data, continuation_token = (
+ self._underlying.get_raw(state_key, continuation_token))
+
+ input_stream = coder_impl.create_InputStream(data)
+
+ self._retrieval_time += time.time() - start_time
+ self._get_raw_called += 1
+
+ if self._retrieval_time > self._warn_interval:
+ _LOGGER.warning(
+ f"Retrieving state {self._get_raw_called} times costed "
+ f"{self._retrieval_time:.0f} seconds. It may be due to insufficient "
+ "state cache size and/or frequent direct access of states.\n"
Review Comment:
I think current cache size could be fetched with `self._state_cache.size()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add warning when retrieving state cache inefficiency detected [beam]
Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on PR #30696:
URL: https://github.com/apache/beam/pull/30696#issuecomment-2010690599
example:

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org