-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Optimize IPCProvider.make_request #842
Comments
Some thoughts.
Any chance you'd like to take a stab at this? |
Sure. For the benchmark I'm going to
Let me know if you have other ideas. |
I tried this script:
The output is
It's about 75% gain. I'm gonna try it on bigger blocks tomorrow. This is the line that does the check for closing brace: That's a quick and dirty way just for testing the idea. The last character is usually \n so I guess I'll need to "right trim" the response before checking for the last character. Update
Almost 10 fold gain. I also tried switching the order in which benchmarks are run, i.e. optimized version first followed by the current version - still 10 fold gain. |
That looks like solid gains. You might check and see if |
Fixed here #849 |
What was wrong?
In the current implementation the response will be parsed on every
recv
from the socket https://github.com/ethereum/web3.py/blob/master/web3/providers/ipc.py#L175If the response is big it can become a bottleneck. E.g. in ETL tasks https://github.com/medvedev1088/ethereum-etl
How can it be fixed?
Is it possible to check the last bytes of the response first to see if they are a valid JSON RPC terminating character such as },] and only if true try to parse JSON?
The text was updated successfully, but these errors were encountered: