Ask for how to implement asynchronous requests #380
Replies: 4 comments
-
After I happily implemented my "toy software cloud drive", I opened a folder with 10MB of images. |
Beta Was this translation helpful? Give feedback.
-
There is currently no true asynchronous interface for Dokan, so you cannot return Anyway. I see a few other issues with your design. First of all, you use blocking |
Beta Was this translation helpful? Give feedback.
-
Yes, as you said, global locking is not a good idea. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all.
I was learning how to get involved in the development of the file system, but I ran into some problems. Network latency leads to having to think about how to do asynchronous reads and writes
I have simply implemented a cloud disk program, using the DokenNet.IDokanOperations2 interface, and locking as much as possible before waiting for the server tcp to return.
In the native test:
IP 127.0.0.1:Port
Disk continuous read/write > 2000MB/s
After mounting Dokan, 1k small files can be copied / read 70 times /s, and 1g large files can be copied at 200 mb / s
But on weak performance devices:
IP x.x.x.x:Port
The network bandwidth is 5M (625kb/s)
Disk continuous read/write 100MB/s
The ping latency ranges from 100ms to 150ms
After mounting Dokan, 1k small files can be copied / read 2 times /s, The transfer speed is lower than 400 kb / s
I know that the low transmission bandwidth is the reason for the network bandwidth.
However, IDokanOperations2.ReadFile will cause the explorer interface to become unresponsive if it does not return.
I expect to know how to prioritize returns when a file is slow to read and write, and asynchronously write data to the caller's stream. I couldn't find an asynchronous interface for DokanNet.
To make it easier for you to understand my intentions, I have uploaded some of my code.
When Explorer opens a folder with more images, it will try to read the images inside to generate thumbnails. If an image is 1mb in size, my current implementation will cause the explorer to freeze for 3 seconds. (150ms latency + 1mb / 400kb/s = 2.71 s)
Here's my earlier implementation, when in high latency (150ms), because of the maximum 64kb (buffer.span.length, transmission is time-consuming 64kb / 400kb/s = 160ms) transferred every 310ms, a 1mb size picture would cause the explorer to freeze for longer. (1mb / 64kb * 310ms = 4960ms)
I saw NtStatus.Pending in the code, but I don't know how to use it. I didn't find a sample code that uses this.
I would appreciate it if someone could point out where the code is available for me to learn.
Here's the code I wrote by feeling to express my intentions. Is pending used this way? When I still don't have the data ready, go straight back to pending until the data is ready
How should pending be used? As long as the explorer doesn't get stuck, the transfer speed is secondary
Thanks!!
Beta Was this translation helpful? Give feedback.
All reactions