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
String split zero copy #46
Conversation
Can you make explicit the method signature of the current |
d9be53d
to
8506b27
Compare
I need convincing. I can see having another split method that does this. We have/had that at Sendence. However changing split to only work on vals is not a good thing. Its perfectly reasonable for me to want to be able to split a ref. This change would disallow that. Rather than changing the existing method, I believe what you want is a new method. |
I suppose with subtyping it would be quite easy to provide two implementations of |
What subtyping are you referring to @malthe? |
I was thinking that with #62 it might be possible to "overload" If that's something we want? An alternative is of course to go with different names but that seems a bit wrong to me – like Hungarian notation almost. I think ergonomics should be a concern here as well as obviously performance. |
I wonder how the performance of It would be interesting to see some benchmarks. |
@jemc that would be an interesting benchmark. did you mean:
|
@SeanTAllen yes, thanks for the correction - I've corrected the comment. |
The benchmark results are:
For what it's worth, ponylang/ponyc#1335 actually runs about 1% faster than Program code: use "ponybench"
actor Main
let length: USize = 1024 * 1024
new create(env: Env) =>
let s = recover ref String.create(length) end
while s.size() < length do
s.append("abcde ")
end
let s': String val = s.clone()
let bench = PonyBench(env)
bench[None]("split", recover val lambda()(s') => s'.split() end end)
bench[None]("split-zc", recover val lambda()(s') => s'.clone().split_zc() end end) |
@malthe thanks for doing this benchmark. I cloned your fork and tried a few variations on the benchmark, and couldn't come up with a case where the With that in mind, I think there is no reason to keep a |
Closing as stale. |
Rendered
Implementation is here: malthe/ponyc@issue-1309...malthe:string-split-zero-copy