Skip to content

Best way to handle fork optimized for sparse reading #2

@posborne

Description

@posborne

CC @nastevens

Hello @mbr. Thanks for putting together this library -- it was great for giving me something to work with starting out for a problem I have been working on.

Unfortunately, the design of the current parser (which requires that the entire device tree be loaded into a buffer in RAM and then a second copy be stored in the data structures) was not suitable for my use cases (In my case, I am dealing with FIT images that contain full kernels and ramdisks weighing in at ~20MB+).

For my use case, I only really care about one specific piece of information hidden in the device tree so I ended up writing a new device tree parser (based partially on the API and implementation of this library) that creates a much lighter weight data structure by reading/seeking out of a file rather than out of a memory buffer. This way, I do not have to pay the memory/cpu cost of allocating (or even reading) large property values from the input file.

I think what I have put together could be useful for other users, and I could see a couple ways of dealing with the change:

  1. Open a PR here that will replace the current library with the new implementation
  2. Offer up the code as a separate repo/crate (also MIT licensed and including your Copyright as well as mine).

Although the new implementation was much more optimized for my current use cases, I can see a few drawbacks to using it:

  • My implementation depends on std as well as the byteorder crate.
  • The original implementation is probably faster for small device trees where all of the data will be used (and especially if the property keys/values will be accessed many times).
  • At the moment, mine lacks a few of the features related to parsing property values.

Thoughts on how to move forward? Right now I am leaning toward the second option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions