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

Optimized fixed ints based on Cython #97

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

psrok1
Copy link
Member

@psrok1 psrok1 commented Jun 19, 2023

Current design is based on metaclasses, int-based classes etc. All of these things slow down object construction which is crucial for performance (see also #95)

  • Redesigned IntType to simplify objects (FixedInt). Changes are breaking, but we need to test it using existing modules to check if we don't break it too much.
  • Added Cython-based implementation although it introduces limitations. For example:
        def __or__(self, FixedInt other):
            return FixedInt(self.longval | other.longval, self.bits, self.sign)
    
        def __or__(self, unsigned long long other):
            return FixedInt(self.longval | other, self.bits, self.sign)
    
    accepts only int that are within unsigned 64-bit range (no negative numbers) and arbitrary FixedInts
    On the other hand long long accepts only signed 64-bit range.
  • Added Python-based implementation for non-2's complement architectures that is opt-in via MALDUCK_PYTHON_INTS environment variable or when import of native extension fails.

TODO:

  • Consider renaming malduck to src. During local development, Python imports package from local directory and fallbacks to Python implementation when .so is not in malduck/ints directory.
  • Modify CI/CD to prepare wheels for x86 glibc/musl (also check other architectures in qemu)
  • Make better tests because some masking/sign extension operations are implemented by ourselves.

@psrok1 psrok1 linked an issue Jun 19, 2023 that may be closed by this pull request
@psrok1 psrok1 marked this pull request as ready for review July 31, 2023 15:33
@psrok1 psrok1 marked this pull request as draft July 31, 2023 15:34
@psrok1 psrok1 force-pushed the feature/fast-fixed-ints branch 2 times, most recently from a348eae to ab9c211 Compare July 31, 2023 16:12
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.

IntType slowness (fixed ints)
1 participant