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

PERF-#367: Use std::fill to fill service shared buffer with a given value #373

Merged
merged 7 commits into from
Nov 7, 2023

Conversation

arunjose696
Copy link
Contributor

@arunjose696 arunjose696 commented Oct 23, 2023

What do these changes do?

In _allocate_shared_memory(self): function we are setting -1 to the service buffer because 0 is a valid value. This operation is a time consuming operation. Changing this to use numpy to speed up the step.

  • first commit message and PR title follow format outlined here

    NOTE: If you edit the PR title to match this format, you need to add another commit (even if it's empty) or amend your last commit for the CI job that checks the PR title to pick up the new PR title.

  • passes flake8 .
  • passes black .
  • signed commit with git commit -s
  • Resolves First put into the shared memory is slower than subsequent one #367
  • tests added and passing
  • module layout described at docs/developer/architecture.rst is up-to-date

@arunjose696
Copy link
Contributor Author

arunjose696 commented Oct 23, 2023

Here are some results running the reproducer with and without changes.

import unidist
import numpy as np
import time

unidist.init()

t0 = time.time()
data = unidist.put(np.arange(10))
t1 = time.time()
print(f"time is {t1 - t0}")

t0 = time.time()
data2 = unidist.put(np.arange(10))
t1 = time.time()
print(f"time is {t1 - t0}")

####Current Master############
time is 4.3809590339660645
time is 0.0005385875701904297

###This pull request ##########
time is 0.38097357749938965
time is 0.0003437995910644531

removing this line to check.
time is 0.002953767776489258
time is 0.00027179718017578125

CPU tested Model name: Intel(R) Xeon(R) Platinum 8276L CPU @ 2.20GHz
Ran with
MODIN_ENGINE=unidist UNIDIST_MPI_SHARED_OBJECT_STORE=True UNIDIST_MPI_BACKOFF=0.0 UNIDIST_IS_MPI_SPAWN_WORKERS=False mpiexec -n 3 python times.py

@arunjose696 arunjose696 force-pushed the FirstPutSlower branch 2 times, most recently from c18551f to 6382d53 Compare October 30, 2023 18:25
@@ -170,6 +170,7 @@ def monitor_loop():
The loop exits on special cancelation operation.
``unidist.core.backends.mpi.core.common.Operations`` defines a set of supported operations.
"""
monitor_logger.debug("Monitor loop started")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
monitor_logger.debug("Monitor loop started")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this looging line here so the init() function in root ends only after the monitor.log file is created and first log is written, Or this file creation step though not very time consuming happens after init() of the root process and could make the first put() slightly slower as the monitor will be ready to recv operations only after creating the logger file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed offline and decided to apply suggestion.

Aside: Is the log file created on the first write or when we call get_logger?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verified again the log file is created when the "first write" is made.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks!

unidist/core/backends/mpi/core/monitor/loop.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/controller/api.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/monitor/loop.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/shared_object_store.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/worker/loop.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/worker/loop.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/worker/loop.py Outdated Show resolved Hide resolved
arunjose696 and others added 3 commits November 6, 2023 02:44
… the worker and monitor loops have started

Signed-off-by: arunjose696 <[email protected]>
Co-authored-by: Iaroslav Igoshev <[email protected]>
@arunjose696 arunjose696 force-pushed the FirstPutSlower branch 2 times, most recently from e1ce634 to 8603282 Compare November 6, 2023 09:00
unidist/core/backends/mpi/core/controller/api.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/memory/_memory.pyx Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/memory/_memory.pyx Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/memory/_memory.pyx Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/memory/memory.cpp Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/memory/memory.h Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/memory/memory.pxd Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/monitor/loop.py Outdated Show resolved Hide resolved
unidist/core/backends/mpi/core/worker/loop.py Outdated Show resolved Hide resolved
@YarShev
Copy link
Collaborator

YarShev commented Nov 6, 2023

Please also rename the PR title and exclude the file unidist/core/backends/mpi/core/memory/_memory.cpp (it is auto-generated by cython) out of this PR.

@YarShev
Copy link
Collaborator

YarShev commented Nov 6, 2023

Some perf measurements would also be helpful.

YarShev and others added 3 commits November 7, 2023 18:48
Signed-off-by: Igoshev, Iaroslav <[email protected]>
Signed-off-by: Igoshev, Iaroslav <[email protected]>
@YarShev YarShev changed the title PERF-#367: Using numpy to alter values of service buffer PERF-#367: Use std::fill to fill service shared buffer with a given value Nov 7, 2023
@YarShev YarShev merged commit abe15f5 into modin-project:master Nov 7, 2023
24 checks passed
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.

First put into the shared memory is slower than subsequent one
2 participants