-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
Exponential data-transfer can be changed to linear #229
Comments
In which version did you spot this ? This is indeed completely useless to have this
I did not spot it in the master branch libjson-rpc-cpp/src/jsonrpccpp/client/connectors/linuxtcpsocketclient.cpp but it is still present in the windows implementation ( libjson-rpc-cpp/src/jsonrpccpp/client/connectors/windowstcpsocketclient.cpp). I see in the linux tcp socket connector and the unix domain socket connector that the stream reader is used, I guess it would be nice to also use it in the windows tcpsocket connector (unless it uses linux features, I haven't checked that). PS: My bad it seems this useless copy was introduced by me since it is in tag v0.7.0 version of file... |
There has been quite a bit of refactoring since I got the code last year. Looks like the exponential data issue is still there. The target will be a cumulative string that would be searched from the beginning each time: (common/streamreader.cpp)
|
So a fix could be add a counter of how many bytes we read and use it as a starting position for the find call. |
Since we are accumulating data transferred in result string, the find becomes exponential as we always search the concatinated string from beginning.
Client file linuxtcpsocketclient.cpp:
Server file linuxtcpsocketserver.cpp:
Change the while loop to:
} while(memchr(buffer, DELIMITER_CHAR, nbytes) == NULL);
Delete the tmp string as well
With these changes, I did a round trip transfer of 10^7 characters in 0.8 seconds instead of 108 seconds.
The text was updated successfully, but these errors were encountered: