You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today i came across this blog http://kaioa.com/node/59, ther author was talking about the performance impact of setting init-capacity for StringBuilder. I quote here the important observation of the author:
"If you take a closer look you can also see that there is some kind of rhythm: the best initial capacities (local optimum) are always a power of two. And the worst results are always just before the next power of two. The perfect results are of course achieved if the required size is used from the very beginning (shown as dashed lines in the diagram) and no resizing happens at all."
And i come to the idea how we can optimize the performance of Japid abit futher. Now we hardcode init-capacity of StringBuilder in constructor of JapidTemplateBaseWithoutPlay. My idea is to have a global tracking mechanism of the actual required size of each template and after a warmup the JapidTemplateBaseWithoutPlay constructor will lookup the ideal init-capacity for each template here.
What do you think?
The text was updated successfully, but these errors were encountered:
smart idea indeed. I had another idea before: each template class holds on to an instance of StringBuilder and each invocation of the same template reuses the same StringBuilder, so eventually the StringBuilder will have a capacity of the largest size it has ever served. There is no smart algorithm required. Of course I need have some mechanism to protect it from some extreme cases.
Oh your idea, i think is still smarter. Very importan, no need of such a automagical algorithm for dynamic tracking, simple to implement -> more stable. Ok, why do you still hesitate to implement it? ^^
Today i came across this blog http://kaioa.com/node/59, ther author was talking about the performance impact of setting init-capacity for StringBuilder. I quote here the important observation of the author:
"If you take a closer look you can also see that there is some kind of rhythm: the best initial capacities (local optimum) are always a power of two. And the worst results are always just before the next power of two. The perfect results are of course achieved if the required size is used from the very beginning (shown as dashed lines in the diagram) and no resizing happens at all."
And i come to the idea how we can optimize the performance of Japid abit futher. Now we hardcode init-capacity of StringBuilder in constructor of JapidTemplateBaseWithoutPlay. My idea is to have a global tracking mechanism of the actual required size of each template and after a warmup the JapidTemplateBaseWithoutPlay constructor will lookup the ideal init-capacity for each template here.
What do you think?
The text was updated successfully, but these errors were encountered: