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

Parallelization #1

Open
dennissergeev opened this issue May 9, 2018 · 2 comments
Open

Parallelization #1

dennissergeev opened this issue May 9, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@dennissergeev
Copy link
Owner

Add an option to execute functions in parallel processes

@dennissergeev dennissergeev added the enhancement New feature or request label May 9, 2018
@dennissergeev dennissergeev self-assigned this May 9, 2018
@dennissergeev
Copy link
Owner Author

Proof of concept:

def foo(df):
    flag = True
    if df.total_dist_km < 300.:
        flag = False
    if flag:
        if ((df.vortex_type != 0).sum() / df.shape[0] > 0.2):
            flag = False
    if flag:
        df['cat'] = 99
    return df

with concurrent.futures.ProcessPoolExecutor(4) as pool:
    TR.data = pd.concat(list(pool.map(foo, [j for i, j in TR.gb], chunksize=10)))

So far it doesn't give any speed-ups, but maybe it will for heavier computations.

@dennissergeev
Copy link
Owner Author

For track density calculation, concurrent execution reduces total time by 2. Example:

with concurrent.futures.ProcessPoolExecutor(4) as pool:
    res = list(pool.map(density, gb_list, chunksize=10))
dens = np.array(res).sum(axis=0)

Needs to be investigated further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant