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

feat(bake): add dependencies to IncrementalGraph #14368

Merged
merged 9 commits into from
Oct 7, 2024

Conversation

paperclover
Copy link
Member

@paperclover paperclover commented Oct 5, 2024

Progress for #14324

Bake now properly tracks dependencies between files. When updating a file, the graph is traversed upwards for dependencies to the route files.

Updating a file now properly indicates which routes were updated (having a tab open on an unaffected route will not yield an update).

Updating a client component will, despite re-bundling SSR code, not invoke a server-side rerender. This is because the client code is sent over and used.

This does not handle an edge case with server files that reside in both the Server and SSR graphs. The first file's imports are not tracked because the second one overrides them. I will fix this later.

To make debugging easier, this also includes a visualizer for the incremental graph. I intend to keep this even in release builds so that if someone messes up their state, it can be explored or dumped.

image

/// Reverse of the slice index operator.
/// Given `&slice[index] == item`, returns the `index` needed.
/// The item must be in the slice.
pub fn indexOfPointerInSlice(comptime T: type, slice: []const T, item: *const T) usize {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not account for alignment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesnt sizeOf return the size of the item in the slice?

if so, this function asserts the item is in the slice; regardless of how the slice is aligned, the item must be at some multiple of the size after the pointers are subtracted.

@@ -8677,6 +8677,14 @@ pub const ServerComponentBoundary = struct {
bun.unsafeAssert(l.list.capacity > 0); // optimize MultiArrayList.Slice.items
return l.list.items(.reference_source_index)[i];
}

pub fn bitSet(scbs: Slice, alloc: std.mem.Allocator, input_file_count: usize) !bun.bit_set.DynamicBitSetUnmanaged {
var scb_bitset = try bun.bit_set.DynamicBitSetUnmanaged.initEmpty(alloc, input_file_count);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to use AutoBitSet here if possible. That will hold the memory inline if it fits.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i dont think autobitset is useful when you can just use stack-fallback allocator, which will hold the memory on the stack and avoid extra branches when reading into the bitset

@paperclover paperclover merged commit fc85a2d into main Oct 7, 2024
49 checks passed
@paperclover paperclover deleted the dave/bake-incremental-graph branch October 7, 2024 21:18
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

Successfully merging this pull request may close these issues.

3 participants