-
Notifications
You must be signed in to change notification settings - Fork 9
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
Deprecate for WeakRefString's InlineString #56
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Jacob Quinn <quinn.jacobd@gmail.com>
I think that deprecating ShortStrings should wait, InlineString doesn't completely replace SSs (it doesn't have a string macro to make using them more convenient, for example), and it really needs some performance testing done, to see how it compares to other string types, such as String and ShortString. (I've already seen a few cases where it is substantially slower - in one simple case, 273x slower!) |
Please share the performance checking you've done; I tested every function defined in the InlineStrings.jl package and it was faster or on par with everything in ShortStrings. I'll find a link to the perf testing I did, but it was pretty substantial. |
I just did some simple tests of |
julia> x = InlineString("hey")
"hey"
julia> y = "hey"
"hey"
julia> typeof(x)
String3
julia> typeof(y)
String
julia> @btime x == y
15.004 ns (0 allocations: 0 bytes)
true
julia> @btime y == y
12.275 ns (0 allocations: 0 bytes)
true
julia> @btime x == x
11.479 ns (0 allocations: 0 bytes)
true
julia> z = ShortString("hey")
"hey"
julia> typeof(z)
ShortString3 (alias for ShortString{UInt32})
julia> @btime y == z
15.442 ns (0 allocations: 0 bytes)
true
julia> @btime y == y
11.114 ns (0 allocations: 0 bytes)
true
julia> x = InlineString("a"^255)
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
julia> y = "a"^255
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
julia> z = ShortString("a"^255)
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
julia> @btime x == y
34.052 ns (0 allocations: 0 bytes)
true
julia> @btime z == y
925.439 ns (0 allocations: 0 bytes)
true sampling other sizes of InlineStrings/ShortStrings seems to show similar results; it seems like ShortStrings gets significantly slower for some reason for the 128/255 byte cases; otherwise, the performance seems about equal for all other sizes. |
I don't care to duplicate efforts.
InlineStrings is just a more complete implementation of this idea.
With a few extra clever tricks.
cc @quinnj