x/tools/go/gcexportdata: reads entire object file, not just the needed type information #48954
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
When using
gcimportdata.NewReader
andgcimportdata.Read
, the entire object file will be read into memory, not just the portion containing type information. For packages that have large variable initializers, or that useembed
, not doing this could save almost 100% of memory usage and I/O.https://play.golang.org/p/kAXdktA3WTD contains an example that loads the archive for https://play.golang.org/p/MvxM7Jlxjhk – a package that embeds a 100 MB file. It demonstrates how much data gets read unnecessarily.
This should be fairly straightforward to fix. The necessary length information exists,
gcimporter.FindExportData
just doesn't expose it. If it did, we could use anio.LimitedReader
.A quickly hacked together patch drops the read amount from 100 MB to 100 bytes.
I'd be happy to send a change, but I'm not sure how the development between
x/tools
'sgcimporter
and the Go compiler'sgcimporter
get synchronized./cc @mdempsky because I'm curious how this interacts with his lazy loading work.
The text was updated successfully, but these errors were encountered: