Stream data table rows into context files and render each context once#20
Open
krlittle wants to merge 2 commits into
Open
Stream data table rows into context files and render each context once#20krlittle wants to merge 2 commits into
krlittle wants to merge 2 commits into
Conversation
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ExportContextnow renders each context once per cycle and caches the rendered output on its accumulator, sogenerate()andgetVisitor()reuse it instead of re-aggregating the same data tables for every visited context file and again in the forced second export cycle (reads per table drop from2 × (F + 2)to2, forFcontext CSVs)Listfirst; column headers come fromDataTable.getType(), so no rows are needed up frontPlainTextand must exist anyway), never the table's rowsProblem
ExportContextreads its referenced data tables back to write.moderne/context/*.csv. It re-read and re-rendered each table once ingenerate(), once for every context CSV visited ingetVisitor(), and again in the forced second cycle — roughly2 × (F + 2)full reads per table (~42× for a repo emitting 19 context CSVs) — and each read materialized the whole table into aList(viaaggregateMatchingTables) and built the entire CSV as oneString. For large repositories (one row per method/class) both CPU and the export phase's peak memory scale with table size, repeated dozens of times per repo.Solution
generate()/getVisitor()read from that cache. Build each CSV by streaminggetRows(...)directly into the writer one row at a time rather than buffering aList. Pairs with Stream CsvDataTableStore.getRows from disk lazily instead of buffering the whole table rewrite#7858, which makesCsvDataTableStore.getRowsitself parse lazily; once released, the store side streams too and a whole table is never held in memory at any layer.Test plan
ExportContextTestpasses unchanged, including the exact CSV-row + markdown content assertions inaggregatesRowsFromMultipleInstancesOfSameDataTableand the cycle-trigger regression — confirming byte-identical outputaggregatesEachReferencedTableExactlyOncePerRun, which installs a countingDataTableStoreand asserts each referenced table is read once per export cycle (2 total), not once per visited context file