Multiprocessing is slower than single process
CONTRIBUTOR
dupe of #1992
2021-03-18T09:10:23Z
https://github.com/huggingface/datasets/issues/2071#issuecomment-801757646
https://api.github.com/repos/huggingface/datasets/issues/2071
MDEyOklzc3VlQ29tbWVudDgwMTc1NzY0Ng==
https://api.github.com/repos/huggingface/datasets/issues/comments/801757646/reactions
2021-03-18T09:10:23Z
https://api.github.com/repos/huggingface/datasets/issues/comments/801757646
https://avatars.githubusercontent.com/u/17948980?v=4
https://api.github.com/users/theo-m/events{/privacy}
https://api.github.com/users/theo-m/followers
https://api.github.com/users/theo-m/following{/other_user}
https://api.github.com/users/theo-m/gists{/gist_id}
https://github.com/theo-m
theo-m
MDQ6VXNlcjE3OTQ4OTgw
https://api.github.com/users/theo-m/orgs
https://api.github.com/users/theo-m/received_events
https://api.github.com/users/theo-m/repos
https://api.github.com/users/theo-m/starred{/owner}{/repo}
https://api.github.com/users/theo-m/subscriptions
User
https://api.github.com/users/theo-m
public
```python
# benchmark_filter.py
import logging
import sys
import time

from datasets import load_dataset, set_caching_enabled


if __name__ == "__main__":
    set_caching_enabled(False)
    logging.basicConfig(level=logging.DEBUG)

    bc = load_dataset("bookcorpus")

    now = time.time()
    try:
        bc["train"].filter(lambda x: len(x["text"]) < 64, num_proc=int(sys.argv[1]))
    except Exception as e:
        print(f"cancelled: {e}")
    elapsed = time.time() - now

    print(elapsed)
```

Running `python benchmark_filter.py 1` (20min+) is faster than `python benchmark_filter.py 2` (2hrs+)