Skip to content

Commit

Permalink
Remove calls with high performance impact
Browse files Browse the repository at this point in the history
Remove some calls that have a high impact on performance and are good
candidates for rewriting or removal.
  • Loading branch information
pentschev committed Oct 23, 2024
1 parent 6697d0d commit 1982736
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
6 changes: 1 addition & 5 deletions cpp/src/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ void Request::checkError()
utils::ucsErrorThrow(_status, _status == UCS_ERR_MESSAGE_TRUNCATED ? _status_msg : std::string());
}

bool Request::isCompleted()
{
std::lock_guard<std::recursive_mutex> lock(_mutex);
return _status != UCS_INPROGRESS;
}
bool Request::isCompleted() { return _status != UCS_INPROGRESS; }

void Request::callback(void* request, ucs_status_t status)
{
Expand Down
12 changes: 4 additions & 8 deletions python/ucxx/ucxx/_lib/libucxx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,6 @@ cdef class UCXWorker():
cdef Tag cpp_tag = <Tag><size_t>tag.value
cdef TagMask cpp_tag_mask = <TagMask><size_t>tag_mask.value

if not self._context_feature_flags & Feature.TAG.value:
raise ValueError("UCXContext must be created with `Feature.TAG`")

with nogil:
req = self._worker.get().tagRecv(
buf,
Expand All @@ -789,13 +786,16 @@ cdef class UCXWorker():
cdef class UCXRequest():
cdef:
shared_ptr[Request] _request
Request* _request_ptr
bint _enable_python_future
bint _completed

def __init__(self, uintptr_t shared_ptr_request, bint enable_python_future) -> None:
self._request = deref(<shared_ptr[Request] *> shared_ptr_request)
self._enable_python_future = enable_python_future
self._completed = False
with nogil:
self._request_ptr = self._request.get()

def __dealloc__(self) -> None:
with nogil:
Expand All @@ -810,7 +810,7 @@ cdef class UCXRequest():
return True

with nogil:
completed = self._request.get().isCompleted()
completed = self._request_ptr.isCompleted()

return completed

Expand Down Expand Up @@ -1407,8 +1407,6 @@ cdef class UCXEndpoint():
cdef shared_ptr[Request] req
cdef Tag cpp_tag = <Tag><size_t>tag.value

if not self._context_feature_flags & Feature.TAG.value:
raise ValueError("UCXContext must be created with `Feature.TAG`")
if arr.cuda and not self._cuda_support:
raise ValueError(
"UCX is not configured with CUDA support, please ensure that the "
Expand Down Expand Up @@ -1439,8 +1437,6 @@ cdef class UCXEndpoint():
cdef Tag cpp_tag = <Tag><size_t>tag.value
cdef TagMask cpp_tag_mask = <TagMask><size_t>tag_mask.value

if not self._context_feature_flags & Feature.TAG.value:
raise ValueError("UCXContext must be created with `Feature.TAG`")
if arr.cuda and not self._cuda_support:
raise ValueError(
"UCX is not configured with CUDA support, please ensure that the "
Expand Down

0 comments on commit 1982736

Please sign in to comment.