-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Rework: toString
to use a buffer
#2087
Comments
To be clear, I do not think we should add a compiler flag to modify the growth behavior. It's complexity we don't need right now and would show little benefit. Switching to a buffer already improves memory consumption a lot. |
Currently
toString
in theruntime/string
module rely's onconcat
for building the output string, this often incurs a performance penality from the many allocations done especially with more complex data structures like nested records. We implemented the bytes literal and astdlib/buffer
module into the language sincetoString
was written. It would make sense to implement a basicbuffer
implementation in the runtime so we can make use of buffers throughout thestdlib
andruntime
. I think this would also help with maintainability of thetoString
function long term.One note is the advantage to
concat
overtoString
, is currently ourstdlib/buffer
grows by powers of 2, in a memory confined environment this behaviour might not be ideal, we could add a new compiler flag though such as--low-memory
which could configure theautogrow
function to grow at a slower pace. This flag also might be useful in the future for other stdlib and runtime functions.The text was updated successfully, but these errors were encountered: