Skip to content
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

Adds a segment builder for merging multiple segments #552

Merged

Conversation

phil-scott-78
Copy link
Contributor

When merging a large number of segments together we were doing a tremendous amount of allocation especially related to strings due to concatenation.

This adds an internal SegmentBuilder that uses a StringBuilder for building up the text rather than creating a new instance and doing a concat operation for each segment.

Here's the perf for a 10,000-node tree.

Before

image

After

image

In the before you'll notice we are doing 44gb of memory allocations, mostly strings. Afterwards thanks to the StringBuilder this drops to 44mb. Performance obviously comes with this too, as the time to build goes from 32s down to 133ms. Not too shabby!

Unit tests all pass, obviously, but @patriksvensson I definitely could use a careful eye and feedback here because I get nervous anytime I write code that messes with the control characters :-)

Fixes #551

When merging a large amount of segments together we were doing a tremendous amount of allocation especially related to strings due to concatination.

This adds an internal SegmentBuilder that uses a stringbuilder for building up the text rather than creating a new instance and doing a concat operation for each segment.
Copy link
Contributor

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Low performance rendering big Tree objects
2 participants