-
Notifications
You must be signed in to change notification settings - Fork 887
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
fix: Fix XmlStringBuilder caching. #569
fix: Fix XmlStringBuilder caching. #569
Conversation
XmlStringBuilder.append(Element) calls into the generic append(CharSequence) method which breaks the caching.
Thanks. Took me a while to figure out what I assume now the issue is, but I am still not sure I understand. You want that Smack/smack-core/src/main/java/org/jivesoftware/smack/util/LazyStringBuilder.java Lines 37 to 41 in d0ec48e
is used (at least that is what your change appears to do), right? But I am not sure how this helps with caching? Could you maybe elaborate on the "breaks the caching" part? I am sure missing something obvious. BTW, the output from the code snipped you posted would be beneficial. I think the thing you want to show with the snippet is that the run time for l1-l5 always stay identical. If so, then I am not sure how your suggested change helps reducing them, since every |
Bump. Note that this is not just a contrived example, it's based on a real IQ with nested ExtensionElements that we use. With the packet debugger enabled we were starting to see timeouts. |
I have it on the radar. But you are aware that your PR currently targets the main dev branch and not the stable release branch. If it is important for you that this hits a release early, then you may want to issue a pull request against the current stable branch. |
I didn't mean to pressure you. We have worked around it (by using XmlStringBuilder.write() instead of toString()), so we don't need it in a release soon. |
I finally found the time to investigate this. \o/ The main cause of the slow performance was that LazyStringBuilder did not cache the length alone. I fixed this with 70e4830. The times of your test then go down from ~12000ms to ~100ms on my machine. I also added your approach in 6322f4f, which can be optionally enabled (via the I was hesitant to make In any case, thanks for reporting this and providing additional data! :) |
XmlStringBuilder.append(Element)
calls into the genericappend(CharSequence)
method which breaks the caching.As a result we see
IQ.toString()
taking a very long time (over 8 seconds for some ~60KB IQs from a real system). Here's a test to demonstrate (see post below)Note that
PacketWriter
usesXmlStringBuilder.write()
and never callstoString()
and its performance isn't affected.