-
Notifications
You must be signed in to change notification settings - Fork 39
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
Get rid of String for internal representations. #43
Comments
Actually I'll show my benchmarks: With this bench:
Using master: Using Master where Using Groundhog with No Strings (Over 2x speedup): Using No Strings but So when it comes to text processing I guess it is a bit more than a bump. Seeing as I would suspect most haskellers would use Text for their programs, this would mean an almost 2x speed up. Edit: There was a memory bug before, but I added |
Thank you, it is an interesting experiment. It looks like the speedup comes mostly from adding Text to PersistValue. The type Can you create a pull request that replaces PersistString with PersistText? Then we can see how replacing String with Text in entity description affects performance. It is a big change that needs some more thought. |
I agree. It is a big change (It started with PersistValue and then I kinda got carried away). There are essentially 3 parts to this:
Changing PersistString to PersistText is where probably 90% of the performance boost came from. But there is more to moving off strings completely than just performance. Many backends support UTF8 table names and fields (interestingly so do Haskell functions). I will work on the PR for isolating the PersistString changes. |
I am going to issue a new major release soon. If you don't have time for PersistText PR now, I can do the change myself and mention you in the commit. |
I did a quick first pass here: I made library dependent strings into Text and SQL related strings into Utf8.Text in BSON, Redis and ReQL and the like are closer to Text than to String so it might be nice to have a more direct relationship for the mappings to the backend.
I also got rid of StringLike interface on
flattenP
since it would've converted into string and back. This also makes it easy to swap out what type Utf8 is, making it easy to try out different string representations.It still needs some more work. So far I converted groundhog, part of groundhog-th and groundhog-sqlite
https://github.com/lykahb/groundhog/compare/master...hansonkd:string-to-text?expand=1
I thought this would have had more of a speed bump, but it looks like it is about the same as current master so I am probably going to put it on hold. Although it still solves the problem of preventing encoding information from being lost (in an intermediate PersistString).
This also removes
read
for integer conversion in favor ofText.Reader
. A parsing library should be found for datetime conversion.Edit:
This should only mean backend changes. Users can keep using Strings and have the same performance as before.
By my current benchmarks it increases the speed of Text fields 2x-4x (compared with Text fields in Master), speeds up query render (see
critLite.hs
) times between 1.5x and 3x, String fields remain about the same performance. Switching from String to Text will be about a 1.5x speedup.The text was updated successfully, but these errors were encountered: