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

Feature/bgp left deep reordering #102

Closed
wants to merge 4 commits into from

Conversation

joachimvh
Copy link
Member

This implements the original TPF query algorithm.

(Performance problem I had was because I executed the promises consecutively).

@joachimvh joachimvh added this to To Do in Development 1.0.0 via automation Mar 7, 2018
@joachimvh joachimvh moved this from To Do to To Review in Development 1.0.0 Mar 7, 2018
@joachimvh joachimvh self-assigned this Mar 7, 2018
@coveralls
Copy link

coveralls commented Mar 7, 2018

Pull Request Test Coverage Report for Build 49

  • 96 of 96 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 43: 0.0%
Covered Lines: 2060
Relevant Lines: 2060

💛 - Coveralls

// Continue clustering as long as different clusters have common variables
do {
// Find a variable that occurs in more than one subpattern
const allVariables = Array.prototype.concat(...clusters.map((cluster) => cluster.variables));
Copy link
Member

Choose a reason for hiding this comment

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

That's a nice shorthand, I'll have to remember that :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

(Totally stole it from stackoverflow somewhere).

Copy link
Member

@rubensworks rubensworks left a comment

Choose a reason for hiding this comment

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

Only some minor comments.

I'm just wondering what the performance of this is, and how it compares to the current BGP actor. Is it always faster/slower? Or only in some cases? If so, would we be able to create a mediator to choose the best actor in each case?


public getBoundOperationIterator(op: Algebra.Operation, bindings: Bindings, context?: {[id: string]: any})
: PromiseProxyIterator<Bindings> {
const getStream = async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? You should be able to put this call directly inside the PromiseProxyIt callback as far as I can see?

Copy link
Member Author

Choose a reason for hiding this comment

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

This felt a bit more readable to me than putting everything in a single block. But yea, no other reason than that.

Copy link
Member

Choose a reason for hiding this comment

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

I would combine it then, as this will save us an unnecessary cb+promise.


const best = {
count: Infinity,
index: -1 };
Copy link
Member

Choose a reason for hiding this comment

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

I would place the closing bracket on the next line, feels a bit cleaner IMHO :-)

public async runOperation(pattern: Algebra.Bgp, context?: {[id: string]: any})
: Promise<IActorQueryOperationOutputBindings> {
const clusters = ActorQueryOperationBgpLeftDeepReordering.findConnectedPatterns(pattern.patterns);
// find cluster with least unbound variables (with the least patterns in case of a tie)
Copy link
Member

Choose a reason for hiding this comment

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

Your comments after here don't start with a capital letter anymore, I would add them for consistency.

cluster.variables.filter((v) => vars.findIndex((val) => val.equals(v)) < 0)), [])
.map((term) => termToString(term));

return { type: 'bindings', bindingsStream, variables };
Copy link
Member

Choose a reason for hiding this comment

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

So this actor doesn't provide metadata?

I know it's not required, but it might be good to provide an estimate if possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Originally I didn't do it because it would require calling the metadata from all patterns not the cluster. But now that metadata is in a separate function I will add it. I do wonder how useful this value is going to be for anyone though. :D

@joachimvh
Copy link
Member Author

Going to rerun the evaluations with this algorithm, but my guess is that it will sometimes be faster and sometimes slower (as the current comparison results with the original TPF client are). But how to determine which one is faster is not really feasible I think. If you can do that you could probably solve a lot of problems for query algorithms :D

@joachimvh joachimvh force-pushed the feature/bgp-left-deep-reordering branch from 3ec1f5e to 04c776b Compare March 8, 2018 11:57
@rubensworks
Copy link
Member

@joachimvh Should this be merged as well? Or do you want to evaluate or make some changes first?

@joachimvh
Copy link
Member Author

I'm currently re-running the evaluations on a separate server to see if the performance is really that bad compared to the others. I'll see after that. Not sure if it is worth merging if the performance is terrible anyway.

@joachimvh
Copy link
Member Author

Reran the tests. For some reason this actor performs well in the beginning but keeps getting worse results the longer the longer the evaluation goes on. Will have to check what's up with that.

@rubensworks
Copy link
Member

That's strange. Perhaps a stream that doesn't get closed and keeps running for some reason, but I wouldn't know this would occur, everything looks fine to me.

@joachimvh
Copy link
Member Author

Yea, will have to look in to how to debug this, apparently I managed to create a memory leak in Comunica I guess :P. It's quite consistent though, did another run on the evaluation and had similar results results, first iteration needs 15s for C1 while the last one needs 50+

@rubensworks
Copy link
Member

@joachimvh Should this be included in release 1.0.0 still?

@joachimvh
Copy link
Member Author

I would say no, unless I manage to fix the "memory leak" thing by this evening.

@joachimvh
Copy link
Member Author

Spent some more time on this. Still no idea what the problem is. :|
I did discover that removing the metadat function entirely sped up performance by 10% which surprised me.

@rubensworks
Copy link
Member

@joachimvh For reference, some changes were made yesterday to the README and package.json templates. Before this is merged, we should update those in this PR as well. (not urgent)

@rubensworks rubensworks added this to To Do in Development Major via automation Mar 19, 2018
@rubensworks rubensworks removed this from To Review in Development 1.0.0 Mar 19, 2018
@rubensworks rubensworks moved this from To Do to In Progress in Development Major Mar 19, 2018
@rubensworks
Copy link
Member

@joachimvh What should we do with this one? Fix it up so that we can merge it? Or close it?

@joachimvh
Copy link
Member Author

Well preferably we should fix it, problem is I don't know what the issue is. :D Should check in if it is magically fixed at this point by all the changes that happened since then. Just closing it seems weird since it should be no problem to do this with Comunica.

@rubensworks
Copy link
Member

I'm closing this PR due to staleness. The branch still exists should we want to fix it in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development Major
  
In Progress
Development

Successfully merging this pull request may close these issues.

None yet

3 participants