Skip to content

Conversation

@sabiwara
Copy link
Contributor

An attempt at the 3rd point mentioned here.

I haven't done proper benchmarks yet, but it seems actually slower by ~1s when trying this with 32 - will look into it later this week.

@sabiwara sabiwara force-pushed the stringio-optimization branch from 0280ff4 to 7bcc4b2 Compare February 20, 2025 14:20
@josevalim
Copy link
Member

Btw, to help us find bugs, I would default the initial state to an empty list.

@sabiwara
Copy link
Contributor Author

sabiwara commented Mar 1, 2025

I've been struggling with this one, the concatenation always seems faster when running the benchmark mentioned above (~5.6s on main, ~7.0s on this branch). My assumption is that this could be due to this optimization in OTP 26.

I updated to use a reverse list rather than a [acc | binary], because this seems faster in individual concatenation benchmarks (at the cost of more memory though).

But even there it isn't an overwhelming improvement over string concatenation which is still occasionally faster, and I can't observe any improvement in StringIO itself.

Maybe I'm missing something, but I'm tempted to close this one and consider StringIO as already close to optimal 😅

@josevalim
Copy link
Member

Thank you for exploring! I am ok with closing this, your call!

@sabiwara
Copy link
Contributor Author

sabiwara commented Mar 1, 2025

Thanks @josevalim 💜
Will close, we can always reopen if we find new ideas or other benchmarks where this approach works better.

@sabiwara sabiwara closed this Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants