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

Add a raw bitmap lookup function #24

Merged
merged 1 commit into from Apr 30, 2020
Merged

Add a raw bitmap lookup function #24

merged 1 commit into from Apr 30, 2020

Conversation

harendra-kumar
Copy link
Member

Got some more performance boost by:

  • Removing dynamic word size handling. We now use a static 64-bit word size. We
    can possibly add a 32-bit version as well and statically select an
    appropriate version based on WORD_SIZE_IN_BITS GHC macro.
  • Removing testBit which caused an additional branch instruction
  • Refactor isCombining such that GHC can reuse code converting char to int

@Bodigrim please take a look.

Got some more performance boost by:
* Removing dynamic word size handling. We now use a static 64-bit word size. We
  can possibly add a 32-bit version as well and statically select an
  appropriate version based on WORD_SIZE_IN_BITS GHC macro.
* Removing testBit which caused an additional branch instruction
* Refactor `isCombining` such that GHC can reuse code converting char to int
Copy link
Collaborator

@Bodigrim Bodigrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch with regards to testBit. I forgot that it uses safe shiftL internally.

-- accessible memory.
--
lookupBit64 :: Addr# -> Int -> Bool
lookupBit64 addr# (I# index#) = W# (word## `and#` bitMask##) /= 0
Copy link
Collaborator

@Bodigrim Bodigrim Apr 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe isTrue# (word2Int# (word## and# bitMask##))? Just to be absolutely sure that there are no allocations.

Ah, sorry, my bad, isTrue# does not work here. Nevermind.

let i = ord c
in if i < 768 || i > 125258
then False
else combiningBitmap i
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to prefer this to i >= 768 && i <= 125258 && combiningBitmap i?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't prefer anyone in particular.

@Bodigrim
Copy link
Collaborator

Looks good to me :)

@harendra-kumar
Copy link
Member Author

Thanks! Merging this.

@harendra-kumar harendra-kumar merged commit 7a9e4e5 into master Apr 30, 2020
@harendra-kumar harendra-kumar deleted the raw-bitmap branch April 30, 2020 03:57
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.

None yet

2 participants