seung-lab / cloud-volume

Read and write Neuroglancer datasets programmatically.
https://twitter.com/thundercloudvol
BSD 3-Clause "New" or "Revised" License
128 stars 43 forks source link

gevent monkey patching will make neuroglancer not working #536

Open jingpengw opened 2 years ago

jingpengw commented 2 years ago

when I turned on the gevent monkey patching, neuroglancer will be blocked and can not be accessed in the browser. I only see black screen. I have turned off the monkey patching, it works but might be slower. I am fine with it now. If you have some better options, it would be better.

william-silversmith commented 2 years ago

I suspect this is not going to be easily solvable, the monkey patching is pretty crude and causes other issues sometimes. A better solution (at the expense of code maintenance cost) would be to rewrite the functions to be async and then use a runner like asyncio or trio instead. This should be possible now that older versions of python without async support are retired. However, it will take some work. gevent was a nice way to gain the benefits of async without the maintenance cost, but I suppose eventually the cost borne by users will exceed the cost borne by maintainers and favor implementing it.

Green threads aren't always better than regular threads. I noticed in early 2019 that they are most important to have when running on a virtualized system such as a GCP server. Ran found that using "taskset" on linux with a single-core threaded program had a similar performance benefit. The main thing seems to be on these systems to keep the process pinned to a single core for a reasonably long time.