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

Added named regions for standalone relations #931

Merged
merged 17 commits into from
Apr 20, 2021

Conversation

Kixiron
Copy link
Contributor

@Kixiron Kixiron commented Mar 9, 2021

This is part one of what I suspect will be a saga of similar changes. This pr adds a named region encompassing each standalone (non-recursive) relation. For further changes I'm reasonably sure I'll have to make much more sweeping changes to the dataflow rendering code, which will be painful but highly beneficial in the long term as it'll become significantly easier to reason about and modify, as well as being less prone to fun little lifetime sinkholes.

@@ -85,14 +85,17 @@ const PROF_MSG_BUF_SIZE: usize = 10_000;
pub type Response<X> = Result<X, String>;

/// Unique identifier of a DDlog relation.
// TODO: Newtype this for type-safety
Copy link
Contributor

Choose a reason for hiding this comment

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

These types are visible all the way from the C API. I therefore wanted them to look like numbers. Would newtyping break that or does struct RelId(usize) look like a usize from C?

Copy link
Contributor Author

@Kixiron Kixiron Mar 9, 2021

Choose a reason for hiding this comment

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

#[repr(transparent)] struct wrappers will have the exact same abi is the inner type, so

#[repr(transparent)]
struct RelationId(usize);

will have the same abi as a usize while still allowing type safety within rust


collection
});
scope.clone().region_named(relation.name(), |region| {
Copy link
Contributor

Choose a reason for hiding this comment

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

So we're using regions to make relation/rule metadata visible to external tools (e.g., debuggers). I didn't realize this would be the case, but I guess it makes sense. For operators, I was under the impression that they all now have _named versions, so we could use those instead, but it looks like there's only a small number of _named operators (threshold_named, reduce_named, and a few more).

Do you know if regions have any runtime cost?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm doing both, regions visually organize things while named operators give details on individual operations. Named regions should have a trivial to undetectable amount of overhead since they're just scoped() invocations that don't change the timestamp (and therefore don't incur the cost of syncing at changing timestamps)

@mihaibudiu
Copy link

We should talk about the long term plans for the compiler.
I believe that the intention was to introduce another layer in the IR, which is closer to the dataflow graph.
This will be a significant refactoring of the code. I hope that some of these changes will not need to be completely reimplemented.

@Kixiron
Copy link
Contributor Author

Kixiron commented Mar 9, 2021

I believe that the intention was to introduce another layer in the IR, which is closer to the dataflow graph.

Yes, I've been planning on this and the subsequent refactors I make should allow that task to be significantly easier if all goes well

@Kixiron Kixiron force-pushed the operator-names branch 4 times, most recently from b4ad845 to e3dc240 Compare March 16, 2021 19:33
@Kixiron
Copy link
Contributor Author

Kixiron commented Mar 16, 2021

The issue as of now seems to be this piece of code and the associated pointer casts that are basically transmutes
image

@Kixiron
Copy link
Contributor Author

Kixiron commented Mar 17, 2021

Well that was exceedingly painful and makes me ever more convinced that we need to switch to a Vec<XFormCollection> design instead of the linked-list style approach we have now. Hopefully tests pass now

@ryzhyk
Copy link
Contributor

ryzhyk commented Mar 17, 2021

Well that was exceedingly painful

It certainly looks that way.

and makes me ever more convinced that we need to switch to a Vec<XFormCollection> design instead of the linked-list style approach we have now. Hopefully tests pass now

The only reason we're not doing this is because depending on the kind of transform the next element in the list can be either XFormCollection or XFormArrangement.

@Kixiron
Copy link
Contributor Author

Kixiron commented Mar 17, 2021

I'm fairly confident that can be made nice to work with given nicely-segmented structs and all that jazz, at minimum an enum

@ryzhyk
Copy link
Contributor

ryzhyk commented Mar 17, 2021

I'm fairly confident that can be made nice to work with given nicely-segmented structs and all that jazz, at minimum an enum

I think so. It will sacrifice a bit of compile-time type checking, which is still better than having all these hacks.

@Kixiron
Copy link
Contributor Author

Kixiron commented Mar 17, 2021

I think it's fixed, but now some of the tests time out for some wonderful reason

is_top_level_scope,
)
} else {
Self::streamless_xform_collection_ref(
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be wrong. This assumes that only the first operator in a rule can be a stream xform and will break otherwise. In practice, this means that if a streaming group_by occurs after some other operators, e.g., streaming join, things will break. I will try to create a counterexample, but may not have the time until later today.

@ryzhyk
Copy link
Contributor

ryzhyk commented Apr 10, 2021

Duplication does suck, and this is what I was trying to avoid with unsafe conversions, but I guess this works.

@Kixiron
Copy link
Contributor Author

Kixiron commented Apr 10, 2021

I'll address it in a follow up PR, it just requires some groundwork from this one

@Kixiron Kixiron requested a review from ryzhyk April 11, 2021 16:14
Copy link
Contributor

@ryzhyk ryzhyk left a comment

Choose a reason for hiding this comment

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

Looks good; I'll fix a small typo and merge (just waiting for other pipelines to complete).

@ryzhyk
Copy link
Contributor

ryzhyk commented Apr 11, 2021

I notice that tests run more slowly in this branch. Might be load variations on the CI machine, but I want to investigate.

@Kixiron
Copy link
Contributor Author

Kixiron commented Apr 13, 2021

Opened timely-dataflow/#382

ryzhyk and others added 3 commits April 13, 2021 16:48
Recent DD patches include some bug fixes, including at least two bugs
that affected our ongoing profiling work.
@ryzhyk ryzhyk merged commit 5f02ba7 into vmware:master Apr 20, 2021
@Kixiron Kixiron deleted the operator-names branch April 20, 2021 02:25
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