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

Slow passing inputs to C++ code #46

Closed
maxitg opened this issue Jun 28, 2019 · 0 comments · Fixed by #453
Closed

Slow passing inputs to C++ code #46

maxitg opened this issue Jun 28, 2019 · 0 comments · Fixed by #453
Labels
weed Something isn't working

Comments

@maxitg
Copy link
Owner

maxitg commented Jun 28, 2019

Passing large sets to C++ code is very slow. I.e., evaluate:

rules = {{{a_, b_}, {a_, c_}, {a_, d_}} :> 
    Module[{$0, $1, $2}, {{$0, $1}, {$1, $2}, {$2, $0}, {$0, $2}, \
{$2, $1}, {$1, $0}, {$0, b}, {$1, c}, {$2, d}, {b, $2}, {d, $0}}]};
AbsoluteTiming[
  set = SetReplace[{{0, 0}, {0, 0}, {0, 0}}, rules, 100]] // First
AbsoluteTiming[SetReplace[set, rules]][[1]]

The two timings produced should be similar, however, the second one is much slower than the other, which means the slow down occurs when the large graph is passed to C++ code.

Version:

  • OS: macOS 10.14.5 (18F203)
  • Wolfram Language Version: 12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019)
  • SetReplace git sha: 7feedca

Additional:
Unit test for SetCases will need to be updated with a smaller time after that's fixed.

@maxitg maxitg added the weed Something isn't working label Jun 28, 2019
@maxitg maxitg added the wss19 label Jul 11, 2019
@maxitg maxitg self-assigned this Jul 13, 2019
@maxitg maxitg added this to the 0.2 (WSS19) milestone Jul 13, 2019
@maxitg maxitg removed this from the 0.2 (Physics Project release) milestone Nov 11, 2019
@maxitg maxitg removed the wss19 label May 11, 2020
@maxitg maxitg removed their assignment May 14, 2020
daneelsan added a commit that referenced this issue Oct 12, 2020
## Changes
* Closes #46.
* Improve performance of `encodeNestedLists` inside `setSubstitutionSystem$cpp.m` by not using `ReplaceRepeated`.

## Examples
```wl
In[]:= rules = {{{a_, b_}, {a_, c_}, {a_, d_}} :> 
    Module[{$0, $1, $2}, {{$0, $1}, {$1, $2}, {$2, $0}, {$0, $2}, \
{$2, $1}, {$1, $0}, {$0, b}, {$1, c}, {$2, d}, {b, $2}, {d, $0}}]};
AbsoluteTiming[set = SetReplace[{{0, 0}, {0, 0}, {0, 0}}, rules, 100]] // First
AbsoluteTiming[SetReplace[set, rules]][[1]]

Out[]= 0.052426
Out[]= 0.026598
```

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/maxitg/setreplace/453)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
weed Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant