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

Release GIL while doing curve functions. #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mayfield
Copy link

Releasing the GIL during compute intensive functions lets threaded
applications scale more effectively. Simple benchmarks on a quad core i7
show a speed up of ~573%.

Simple benchmark used:

import axolotl_curve25519 as curve
import os
import threading

randm32 = os.urandom(32)
randm64 = os.urandom(64)

private_key = curve.generatePrivateKey(randm32)
public_key = message = curve.generatePublicKey(private_key)
import time

calcs = 0

def some():
    for i in range(10000):
        curve.calculateAgreement(private_key, public_key)
        signature = curve.calculateSignature(randm64, private_key, message)
        curve.verifySignature(public_key, message, signature)
        global calcs
        calcs += 1

for test in range(3):
    print("\nTEST:", test)
    calcs = 0
    threads = [threading.Thread(target=some) for i in range(4)]
    for x in threads:
        x.start()
    s = time.time()
    for x in threads:
        x.join()
    took = time.time() - s
    print("Took", took, calcs / took)

Releasing the GIL during compute intensive functions lets threaded
applications scale more effectively.  Simple benchmarks on a quad core i7
show a speed up of ~573%.
@mayfield
Copy link
Author

Forgot to mention, single threaded benchmarks didn't show any measurable slowdown.

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.

1 participant