Skip to content

Release GIL while doing curve functions.#21

Open
mayfield wants to merge 1 commit into
tgalal:masterfrom
mayfield:master
Open

Release GIL while doing curve functions.#21
mayfield wants to merge 1 commit into
tgalal:masterfrom
mayfield:master

Conversation

@mayfield

Copy link
Copy Markdown

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
Copy Markdown
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