-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Concept: codegen ignores parameter passing #16897
Labels
Comments
This was referenced Feb 1, 2021
Clyybber
added a commit
to Clyybber/Nim
that referenced
this issue
Feb 2, 2021
Clyybber
added a commit
that referenced
this issue
Feb 2, 2021
narimiran
pushed a commit
that referenced
this issue
Feb 4, 2021
narimiran
pushed a commit
that referenced
this issue
Feb 4, 2021
ardek66
pushed a commit
to ardek66/Nim
that referenced
this issue
Mar 26, 2021
ardek66
pushed a commit
to ardek66/Nim
that referenced
this issue
Mar 26, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tracked down a serious performance bug to how concepts ignore parameter passing rules.
Usually Nim types are automatically passed by reference when they go over 24 bytes which avoids worrying about mutability.
However concepts ignore that and they even ignore the
{.byref.}
pragma.This can lead to horrible codegen for large types, for example for Biginteger used in cryptography (mratsim/constantine#146) or serialization libraries which might want to use a
concept
to serialize any type.This is the prologue before any function calls to the
Fp2
type in my library (think complex of BigInt)Unfortunately I also need Fp4 (complex of complex) and Fp12 (you get the gist) which means I get a significant penalty.
I have been diligently recording all the AAA optimizations that could be done in my problem domain including algebraic, algorithmic and assembly (https://github.com/mratsim/constantine/blob/master/docs/optimizations.md).
I did the most important ones, as shown by very close performance to top (with 10 nanoseconds) for types that don't use concept: https://hackmd.io/@zkteam/eccbench#G1-mixed-additiondoubling
However my library drop by 2x on types that use concepts: https://hackmd.io/@zkteam/eccbench#G2-mixed-additiondoubling
Test case
Notice how a and b are not pointers
The text was updated successfully, but these errors were encountered: