olekukonko / tablewriter

ASCII table in golang
MIT License
4.29k stars 367 forks source link

Fix WrapWords excessive memory utilization #205

Closed horkhe closed 1 year ago

horkhe commented 2 years ago

When feeding production data to this library we discovered that function WordWrap had O(n*n) memory complexity, that resulted in huge amounts of memory allocated when processing even relatively small strings. We are talking Gigabytes that made our production services killed with OOM. This PR implements 2 optimisations:

horkhe commented 2 years ago

@olekukonko any chance to get this PR looked at?

olekukonko commented 1 year ago

@horkhe sorry for the late response, this is wonderful, will take my time to look at this next week so that it can be merged

olekukonko commented 1 year ago

@horkhe can you kindly update your PR and resolve merge conflicts, I Would really like to merge this performance improvement. thank you

horkhe commented 1 year ago

@olekukonko sorry for the late response. I have rebased this PR, please take a look.

horkhe commented 1 year ago

@olekukonko any chance to get this merged?

horkhe commented 1 year ago

@olekukonko any chance to get this merged?

olekukonko commented 1 year ago

@horkhe will look at this this weekend and revert. Thank you for being consistent.

horkhe commented 1 year ago

@olekukonko a friendly reminder.

horkhe commented 1 year ago

Thanks a lot! Could you please also tag the master with v0.0.6, so it can be picked up by go mod.