catalyst-cooperative / ferc-xbrl-extractor

A tool for converting FERC filings published in XBRL into SQLite databases
MIT License
11 stars 0 forks source link

Fix memory issues #142

Closed zschira closed 9 months ago

zschira commented 9 months ago

This PR fixes the high memory usage introduced in 1.0.0. This problem was caused by parsing Instance's at the beginning, and passing the parsed objects to the worker processes. These objects are quite large, and get copied when passed to subprocesses, which lead to huge increases in total memory usage. This PR reverts to parsing these objects when they are needed in each subprocess. It also slightly reworks some integration tests to accommodate this change.

codecov[bot] commented 9 months ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +1.34% :tada:

Comparison is base (9e2633f) 91.75% compared to head (94fa9d7) 93.09%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #142 +/- ## ========================================== + Coverage 91.75% 93.09% +1.34% ========================================== Files 8 8 Lines 594 594 ========================================== + Hits 545 553 +8 + Misses 49 41 -8 ``` | [Files Changed](https://app.codecov.io/gh/catalyst-cooperative/ferc-xbrl-extractor/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalyst-cooperative) | Coverage Δ | | |---|---|---| | [src/ferc\_xbrl\_extractor/instance.py](https://app.codecov.io/gh/catalyst-cooperative/ferc-xbrl-extractor/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalyst-cooperative#diff-c3JjL2ZlcmNfeGJybF9leHRyYWN0b3IvaW5zdGFuY2UucHk=) | `93.70% <100.00%> (-0.66%)` | :arrow_down: | | [src/ferc\_xbrl\_extractor/xbrl.py](https://app.codecov.io/gh/catalyst-cooperative/ferc-xbrl-extractor/pull/142?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=catalyst-cooperative#diff-c3JjL2ZlcmNfeGJybF9leHRyYWN0b3IveGJybC5weQ==) | `91.46% <100.00%> (+10.74%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.