Skip to content

Commit f6c416a

Browse files
authored
Avoid lock if serialization result is already cached (#58722)
The GIL makes checking `self._serialize_cache is not None` atomic, so we don't need lock. Signed-off-by: Xinyuan <[email protected]>
1 parent b8277d5 commit f6c416a

File tree

1 file changed

+2
-0
lines changed
  • python/ray/air/util/tensor_extensions

1 file changed

+2
-0
lines changed

python/ray/air/util/tensor_extensions/arrow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
127127

128128
def __arrow_ext_serialize__(self) -> bytes:
129129
"""Serialize the extension type using caching if enabled."""
130+
if self._serialize_cache is not None:
131+
return self._serialize_cache
130132
with self._cache_lock:
131133
if self._serialize_cache is None:
132134
self._serialize_cache = self._arrow_ext_serialize_compute()

0 commit comments

Comments
 (0)