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

MapFunction is very slow at Ray engine #1838

Closed
dchigarev opened this issue Jul 28, 2020 · 1 comment · Fixed by #1940
Closed

MapFunction is very slow at Ray engine #1838

dchigarev opened this issue Jul 28, 2020 · 1 comment · Fixed by #1940
Assignees
Labels
bug 🦗 Something isn't working Performance 🚀 Performance related issues and pull requests. question ❓ Questions about Modin Ray ⚡ Issues related to the Ray engine
Milestone

Comments

@dchigarev
Copy link
Collaborator

dchigarev commented Jul 28, 2020

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): All, (Ray)
  • Modin version (modin.__version__): Current master
  • Python version: 3.7.5
  • Code we can use to reproduce:
import numpy as np
import string
import csv
import os
from timeit import default_timer as timer

RAND_LOW = -100
RAND_HIGH = 100
N = 30000
M = 1000
TEST_FILENAME = os.path.abspath(f"int_dataset-{N},{M},{RAND_LOW},{RAND_HIGH}.csv")


def generate_data_file(filename, row_n, col_n):
    letters = list(string.ascii_letters)
    columns = [f"col{i}" for i in np.arange(col_n)]

    with open(filename, "w") as file:
        writer = csv.writer(file, delimiter=",")
        writer.writerow(columns)
        for _ in np.arange(row_n):
            writer.writerow(np.random.randint(RAND_LOW, RAND_HIGH, col_n))


if __name__ == "__main__":
    import pandas
    import modin.pandas as pd

    if not os.path.exists(TEST_FILENAME):
        generate_data_file(TEST_FILENAME, N, M)

    md_df = pd.read_csv(TEST_FILENAME)
    print("file readed")
    t1_md = timer()
    md_res = print(md_df.abs())
    t2_md = timer()

    print("Modin:", t2_md - t1_md)

Describe the problem

Related code will measure the working time of abs, which is implemented via MapFunction, that call map_partitions inside partition_manager. The problem is that, it works really slow at ray execution engine, but after changing map_partitions to lazy_map_partitions it starts to work fine:

112 cores:
	map_partitions: 2.6236
	lazy_map_partitions: 0.1817

I've run this code at python execution engine and didn't notice such a problem.
So, is just applying function to partitions is not async at Ray? Are there any limitations of using lazy_map_partitions instead of map_partitions? Can we just change map_partitions to lazy_map_partitions everywhere in modin?
Actually, the difference is not so critical for machines which have not many cores, because it has fewer partitions and so less places to possible blocks

8 cores:
	map_partitions: 0.2313
	lazy_map_partitions: 0.1215

@devin-petersohn please take a look

@dchigarev dchigarev added bug 🦗 Something isn't working Performance 🚀 Performance related issues and pull requests. question ❓ Questions about Modin Ray ⚡ Issues related to the Ray engine labels Jul 28, 2020
@devin-petersohn
Copy link
Collaborator

We can certainly test this for all operations. The lazy_map_partitions does make some assumptions, but it would be a good optimization for the interactive case.

MapReduceFunction might give some trouble, but I think we can work around that. Let's do this for the next release.

@devin-petersohn devin-petersohn added this to the 0.8.1 milestone Jul 28, 2020
@dchigarev dchigarev self-assigned this Aug 21, 2020
dchigarev added a commit to dchigarev/modin that referenced this issue Aug 27, 2020
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
dchigarev added a commit to dchigarev/modin that referenced this issue Aug 27, 2020
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🦗 Something isn't working Performance 🚀 Performance related issues and pull requests. question ❓ Questions about Modin Ray ⚡ Issues related to the Ray engine
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@devin-petersohn @dchigarev and others