Replies: 4 comments 4 replies
-
I pushed some commits to eliminate uncertainty over the performance problem: First I now use a modified |
Beta Was this translation helpful? Give feedback.
-
Ha, this is very interesting! I will take a look soon but would love to study it and see if/how we can improve things. |
Beta Was this translation helpful? Give feedback.
-
The problem is probably entirely due to the implementation of vector:
runs in 0,00 - 0,01 seconds on my machine while:
takes 0,13-0,15 seconds. The same happens when we use |
Beta Was this translation helpful? Give feedback.
-
vector is actually storing kk\_box\_t which behaves like ptr. but for primitive types, it is specialized to hold the value in place.
\-------- Original Message --------
On Jan 12, 2021, 3:04 AM, Anton Felix Lorenzen < ***@***.***> wrote:
The problem is probably entirely due to the implementation of vector:
```
#include <vector>
int main() {
size_t n = 10000000;
std::vector<char> v(n, 'a');
for(size_t i = 0; i < n; ++i) {
v.at(i) = 'b';
}
}
```
runs in 0,00 - 0,01 seconds on my machine while:
```
module bench
public fun main() {
val n = 10000000
var v := vector(n, 'a')
for(0, n - 1) fn(i) {
v[i] := 'b'
}
}
```
takes 0,13-0,15 seconds. The same happens when we use `Bool/boolean` or `int/size_t` as data for the vector.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, [view it on GitHub][], or [unsubscribe][].![AEZNMJOD4PIAJBISARKQ7SDSZNDURA5CNFSM4VMIVSL2YY3PNVWWK3TUL52HS4DFWFCGS43DOVZXG2LPNZBW63LNMVXHJKTDN5WW2ZLOORPWSZGOAACDFXQ.gif][]
[view it on GitHub]: #131 (comment)
[unsubscribe]: https://github.com/notifications/unsubscribe-auth/AEZNMJMIHX7TTHKEW44JRH3SZNDURANCNFSM4VMIVSLQ
[AEZNMJOD4PIAJBISARKQ7SDSZNDURA5CNFSM4VMIVSL2YY3PNVWWK3TUL52HS4DFWFCGS43DOVZXG2LPNZBW63LNMVXHJKTDN5WW2ZLOORPWSZGOAACDFXQ.gif]: https://github.com/notifications/beacon/AEZNMJOD4PIAJBISARKQ7SDSZNDURA5CNFSM4VMIVSL2YY3PNVWWK3TUL52HS4DFWFCGS43DOVZXG2LPNZBW63LNMVXHJKTDN5WW2ZLOORPWSZGOAACDFXQ.gif
|
Beta Was this translation helpful? Give feedback.
-
I ported Edmonds Algorithm for computing a maximum cardinality matching for a graph from C++ to Koka and uploaded it to my Github. Aside from some compiler bugs I found, it worked really well: I am amazed that it is possible to write an imperative algorithm in a functional programming language!
Performance is pretty bad so far; even though I probably can't share the instances, here is an overview:
While the algorithm is exactly the same, I swapped out some datastructures: At a few places I used a list for a stack where the C++ code used a vector and in the
find-cycle
function I used a list instead of a set. But most of the performance problem seems to be from unnecessary allocations: On some larger instances the Koka code simply allocates all my memory and fails. I will try to fix these leaks; hopefully that pushes the code into the same ballpark as C++.Beta Was this translation helpful? Give feedback.
All reactions