Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-memory FS data structure #355

Closed
joliss opened this issue Jan 30, 2018 · 2 comments
Closed

In-memory FS data structure #355

joliss opened this issue Jan 30, 2018 · 2 comments

Comments

@joliss
Copy link
Member

joliss commented Jan 30, 2018

Copying from Twitter. (Cc @rwjblue, @hjdivad.)

@joliss:

Making an in-memory FS data structure / API for Broccoli ecosystem (maybe core). Very simple.

file = Buffer
symlink = string
directory = Map (maps file names to Buffer/string/Map)

Must not mutate; thus === tests deep equality.

Future-proof?

Helper methods (walking etc.) would be functions in separate package(s).

diff(dir1, dir2) is cheap.

If we make it core API, Broccoli can automatically (de)materialize to/from FS on plugin boundaries as needed.

I think I'm missing some serious issue. But can't figure out what.

I considered doing proper Dir/File/Symlink classes, or {type: 'symlink', value: '/target'}-style plain objects, but if we can get away with using Map/Buffer/string directly we gain performance.

(I've come around to thinking that "plain directories on the filesystem" might've been a suboptimal choice of abstraction, due to overhead and cross-platform issues. Perhaps in the future most Broccoli plugins just communicate via in-memory objects, and physical FS becomes exception rather than rule?)

@stefanpenner:

So, we have very limited memory on node. Keeping files on disk, is very important (atleast files over some threshold).

I believe keeping the files (over some size) on disk, but keeping the symlinks in memory strikes the balance we need.

often times, we don't see performance issues with reading the real file from disk, rather we see issues:

  • dirty checking
  • creating/maintaining symlinks
  • creating/maintaining a large number of folders

It's also worth pointing out, that reifing an entire directory tree can be costly and can often be avoided. Reducing initial scan/rebuild costs.

Example:

new Concat(new Funnel('bower_components'), { headerFiles: ['moment/moment.js ] });

@joliss
Copy link
Member Author

joliss commented Jan 30, 2018

As for memory usage, I agree most plugins should write to cachePath and return symlinks into it, instead of in-memory Buffers. We could even consider going without Buffer support to encourage this. I'm really unsure about this.

As for reifying directory trees, if we are able to do it incrementally, we should be fine, right? I'm writing a function for that right now.

@stefanpenner
Copy link
Contributor

This seems to have gone stale, there are additional ways to improve build performance. We can drive that work from concrete problems, and iterate to a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants