并行处理中的内存问题使用Outlot 4时,在Outlot 3中不是这样

2024-05-15 07:46:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个根文件,这个根文件在Google drive上的这个link上可用,当我使用并行处理将它转换为根3中的数组时,它花费的时间和内存更少。我使用的代码类似于

from concurrent.futures import ThreadPoolExecutor
executor = ThreadPoolExecutor(8)

branches = pd.DataFrame.from_dict(uproot.open(''+file_with_path+'')[''+tree_name+''].arrays(namedecode='utf-8', executor = executor))

但现在它消耗了我在根4中的所有内存,可能是我没有正确地执行它。你能看一下吗?而且它也不像以前那么快了

from concurrent.futures import ThreadPoolExecutor
executor = ThreadPoolExecutor(8)

input_tree = uproot.open('/path/10k_events_PFSimplePlainTree.root:PlainTree', decompression_executor=executor)

branches = input_tree.arrays(library='pd', decompression_executor=executor)

@jpivarski和我在本link的问题上讨论了这一点,他建议这可能只是多了10%的内存,但对我来说这超过了10%。可能会增加60-80%


Tags: 文件path内存fromimporttreelinkopen