Skip to content

Explicitly disable SIMD128/256 support for HACL* on aarch64-linux #135032

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

Open
Zheaoli opened this issue Jun 2, 2025 · 7 comments · May be fixed by #135033
Open

Explicitly disable SIMD128/256 support for HACL* on aarch64-linux #135032

Zheaoli opened this issue Jun 2, 2025 · 7 comments · May be fixed by #135033
Labels
3.14 bugs and security fixes 3.15 new features, bugs and security fixes build The build process and cross-build extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@Zheaoli
Copy link
Contributor

Zheaoli commented Jun 2, 2025

Bug report

Bug description:

https://discuss.python.org/t/supporting-simd-on-aarch64-linux/94188/3

SIMD128 on linux arm64 is not good enough(same with the MacOS)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@Zheaoli Zheaoli added the type-bug An unexpected behavior, bug, or error label Jun 2, 2025
Zheaoli added a commit to Zheaoli/cpython that referenced this issue Jun 2, 2025
@picnixz picnixz added extension-modules C modules in the Modules dir pending The issue will be closed if no feedback is provided labels Jun 2, 2025
@picnixz
Copy link
Member

picnixz commented Jun 2, 2025

As I said on the PR, please present benchmarks (I'd like to know how worse it is). And please do the same for SIMD-256 as results may be different (don't forget to build it using --enable-optimizations and --with-lto)

@Zheaoli
Copy link
Contributor Author

Zheaoli commented Jun 2, 2025

don't forget to build it using --enable-optimizations and --with-lto

Thanks for the remind, I'm working on it(

@picnixz picnixz added type-feature A feature request or enhancement build The build process and cross-build and removed type-bug An unexpected behavior, bug, or error pending The issue will be closed if no feedback is provided labels Jun 2, 2025
@picnixz picnixz changed the title Disable the SIMD128/SIMD256 for Linux arm64 explictly Explicitly disable SIMD128/256 support for HACL* on aarch64-linux Jun 2, 2025
@picnixz picnixz added type-bug An unexpected behavior, bug, or error and removed type-feature A feature request or enhancement labels Jun 2, 2025
@picnixz
Copy link
Member

picnixz commented Jun 2, 2025

Since this is affecting BLAKE-2 and HMAC only, we only need to backport it until 3.14 as BLAKE-2 was not in 3.13 I think.

@picnixz picnixz added 3.14 bugs and security fixes 3.15 new features, bugs and security fixes labels Jun 2, 2025
@Zheaoli
Copy link
Contributor Author

Zheaoli commented Jun 3, 2025

After test, The result is the same

import timeit
import random
from string import ascii_letters
from hashlib import blake2s

tmep_string = "".join([random.choice(ascii_letters) for _ in range(1024)])

def main():
    blake2s_hash = blake2s(tmep_string.encode("utf-8")).hexdigest()

if __name__ == "__main__":
    # print(timeit.timeit(main, number=1000000))
    print(timeit.timeit("blake2s(tmep_string.encode('utf-8')).hexdigest()", globals=globals(), number=1000000))
    # print(timeit.timeit("blake2s(tmep_string.encode('utf-8')).hexdigest()", number=1000000))  # This will fail without globals

This is the result with SIMD

ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.4876955619997716
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.4599792300000445
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.4746942629999467
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.4710460269998293
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.4790154759998586
ubuntu@ip-172-31-6-42:~/cpython$ ./configure --with-builtin-hashlib-hashes=md5,sha1,sha2,sha3,blake2 --enable-optimizations --with-lto^C
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.470140725999954
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.472699333000037
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.456732337000176
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.456266343000152
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.452893915000004
ubuntu@ip-172-31-6-42:~/cpython$ ./python demo.py 
2.458339425000304

And the result without SIMD

ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.4618775650001226
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.419546210000135
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.419580041000245
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.4346035089997713
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.4218126690002464
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.419804486999965
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.410035002999848
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.424998641000002
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.4183685279999736
ubuntu@ip-172-31-6-42:~/cpython-original$ ./python demo.py 
2.4080212740000206

@Zheaoli
Copy link
Contributor Author

Zheaoli commented Jun 3, 2025

And please do the same for SIMD-256 as

BTW, here's no SIMD-256 for aarch64 yet

@Zheaoli
Copy link
Contributor Author

Zheaoli commented Jun 3, 2025

All test on AWS m8g.2xlarge, https://instances.vantage.sh/aws/ec2/m8g.2xlarge

@Zheaoli
Copy link
Contributor Author

Zheaoli commented Jun 6, 2025

ping @picnixz ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 bugs and security fixes 3.15 new features, bugs and security fixes build The build process and cross-build extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants