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

Major Subsystem Rewrite (Reconciler Mk5) #217

Merged
merged 129 commits into from
Aug 27, 2019
Merged

Major Subsystem Rewrite (Reconciler Mk5) #217

merged 129 commits into from
Aug 27, 2019

Conversation

LPGhatguy
Copy link
Contributor

@LPGhatguy LPGhatguy commented Jul 16, 2019

This PR reimplements most of the big chunks in Rojo to shift their philosophy, enable some new features, and make it easier to understand and edit the codebase in the future.

Remaining Work

  • Project format parity
    • init.lua, init.server.lua, and init.client.lua
    • foo.meta.json
    • init.meta.json
    • Project metadata like $ignoreUnknownInstances
  • Revisit ImfsEntry API, potentially using generational_arena instead of spamming PathBuf
  • Rebuild file watcher on top of new IMFS
  • Plumb metadata through SnapshotMiddleware
  • Build patch format to send over network
  • Rebuild RbxSession and web server with new project lifecycle
  • Update plugin with new protocol revision
  • Write functional tests for rojo serve?
  • Write benchmarks on master, port to this branch
  • Delete old code

Philosophy Change

Instead of reading the project structure out of the project file at initialization time, the project file is discovered organically through the snapshot middleware! This has a few awesome side effects:

  • Project auto-reloading: we just snapshot the entire project over again
  • Nested projects: the top-level project and nested projects work the same
  • Project files no longer necessary: rojo build can now operate on any file that Rojo can turn into an instance!
    • Convert a model from rbxm to rbxmx: rojo build input.rbxm -o output.rbxmx
    • Turn a Lua file into a model: rojo build main.lua -o MyPlugin.rbxmx

In-memory filesystem (IMFS)

The in-memory filesystem was rewritten to fetch files lazily instead of recursively reading in all files. I saw this as a prerequisite for nested projects so that we would avoid reading in lots of files accidentally.

All methods on the IMFS require exclusive mutable access, which makes some operations awkward since even reading can result in mutation. There might be a slightly cleaner approach involving interior mutability, possibly wrapping the data storage itself in an Rc or Arc.

Snapshot Subsystem

The snapshot subsystem was rewritten in order to break apart the code that generates patches and the code that applies them, which isolates the different forms of complexity.

I'm considering making applying a patch return a different kind of patch that actually gets sent over the network that would include ID information on instances that were created. That information is critical for correctly applying patches in the Rojo plugin!

Snapshot Middleware

The giant ball of mud in rbx_snapshot.rs for determining how to turn files into instances was broken apart into a folder of "snapshot middleware". A middleware is a struct that implements the SnapshotMiddleware trait. Examples of middleware are support for .lua scripts, support for .rbxm models, or a middleware that implements all user plugins!

The middleware trait defines how to turn in-memory files into instances, as well as instances to file snapshots: two-way sync! There's still work to do in adding the additional metadata context needed for live-syncing.

I'm not sure if generating snapshots of files is tractable. There is a single way to turn files into instances, but many different ways to turn instances back into files. While snapshots work well for the former case, it's possible that they're not enough (even with extra context) for two-way sync and we might need to revise this a bit.

Differences from Reconciler Mk4 (previous experiment)

This approach is the successor to #198. In this branch, the goal is to be less pedantic about child ordering than the reconciler-mk4 branch while still trying to accomplish the same overall goal.

The branch does not currently preserve child order across mutations. We can apply a similar strategy to this branch as we did to the current master branch if it's important.

This was referenced Jul 16, 2019
@LPGhatguy LPGhatguy changed the title Reconciler Mk5 Major Subsystem Rewrite (Reconciler Mk5) Aug 17, 2019
@LPGhatguy LPGhatguy marked this pull request as ready for review August 27, 2019 22:00
@LPGhatguy
Copy link
Contributor Author

0.5.0 is released, so now this can go into master and become the base for a new lineage of Rojo releases!

@LPGhatguy LPGhatguy merged commit fea303a into master Aug 27, 2019
@LPGhatguy LPGhatguy deleted the reconciler-mk5 branch August 30, 2019 22:07
Dekkonot pushed a commit to UpliftGames/rojo that referenced this pull request Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants