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

Use rewrite rules instead of some specialization #93

Merged
merged 1 commit into from
Jul 15, 2018

Conversation

nobrakal
Copy link
Contributor

Hi,

Trying to improve the MaybeNonEmpty version, I discovered that the rewrite rules are very powerful for edgeList (it comes from the quickness of AdjacencyIntMap):

edgeList

Description: Produce a list of the edges in the graph

Mesh

100
Alga 77.91 μs
AlgaOld 206.3 μs

Clique

100
Alga 2.347 ms
AlgaOld 7.619 ms

Circuit

100
Alga 39.63 μs
AlgaOld 118.9 μs

SUMMARY:

  • Alga was the fastest 3 times

ABSTRACT:
(Based on an average of the ratio between largest benchmarks)

  • Alga was 2.94 times faster than AlgaOld

@snowleopard
Copy link
Owner

edgeCount: 0.41 (good)
edgeList: 0.32 (good)

@nobrakal Awesome, thank you!

Will the same come for non-empty graphs?

@nobrakal
Copy link
Contributor Author

Will the same come for non-empty graphs?

I think yes, as well as many SPECIALIZE and other RULES of the Algebra.Graph module :)

So since we make no use for now of rules pragma in Algebra.Graph.NonEmpty, I don't know if it worth it adding only one or two here.

(In fact, I already added almost all of these rules in Algebra.Graph.NonEmpty for my work related to #90 )

@snowleopard
Copy link
Owner

Right, I see. We could split the work on non-empty graphs into a separate PR.

as well as many SPECIALIZE and other RULES of the Algebra.Graph module :)

Are these essentially the same as in this PR? In this case, I think it makes sense to combine all such changes together in one PR. Do you agree? If yes, I'll wait for further commits.

@nobrakal
Copy link
Contributor Author

Are these essentially the same as in this PR?

Yep this is mainly specialize and rules pragma. In fact, it would be great to add these pragmas directly into the ToGraph class when possible, so it benefit other implementations. What do you think ?

@snowleopard
Copy link
Owner

If you manage to do this at the ToGraph class level it would be great, of course. But will that actually work?

@nobrakal
Copy link
Contributor Author

But will that actually work?

You were right, I was a bit optimistic... I as not able to sneak this into the ToGraph class (I think this is due to TypeFamilies, which make the simple type-match of rewrite rules a bit complicated).

So I think it is a good idea to open an other PR concerning non-empty graphs, since there will be some different work unrelated to edgeList

@snowleopard
Copy link
Owner

OK, sounds good. Then I'm waiting for further Graph-related commits.

@nobrakal
Copy link
Contributor Author

I'm waiting for further Graph-related commits.

I do not have any :) Do you see anything missing for Algebra.Graph ?

@snowleopard snowleopard merged commit 77155b3 into snowleopard:master Jul 15, 2018
@snowleopard
Copy link
Owner

Ah, I think I just misunderstood one of your earlier messages :) Merged now!

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.

2 participants