molejar / pyFDT

Flattened Device Tree Python Module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance issue when writing large images

MartinBonner opened this issue · comments

PropWords.to_dtb contains the code:

        blob = pack('>III', DTB_PROP, len(self.data) * 4, strpos)
        for word in self.data:
            blob += pack('>I', word)

This ends up allocating O(n**2) space. If you are writing a full blown image (.itb) rather than a device tree the program appears to hang.

I have a patch which uses bytes.join of a list comprehension. It also uses struct.Struct to avoid compiling the format millions of time. This makes loading a large DTB noticeably snappier. I now need to find out if my employer will allow me to submit a PR.

See PR #11 (How do I link PRs and Issues?)

Thanks for fixation

Fixed.