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

update batch sizes to minimize idle cores #295

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backtesting/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,8 @@ def _optimize_grid() -> Union[pd.Series, Tuple[pd.Series, pd.Series]]:
names=next(iter(param_combos)).keys()))

def _batch(seq):
n = np.clip(len(seq) // (os.cpu_count() or 1), 5, 300)
bs = np.ceil(len(seq) / (os.cpu_count() or 1)).astype(int)
n = np.clip(bs, 1, 300)
kernc marked this conversation as resolved.
Show resolved Hide resolved
for i in range(0, len(seq), n):
yield seq[i:i + n]

Expand Down