How to improve the performance of virtual scsi miniport disk?

Hi everyone.
I write a virtual scsi miniport disk. It use file to store data. But the
performance is bad. Just about 1.0MB/s, the real hard disk is 50.0MB/s. Is
there one appropriate way to improve the transfer speed.
Thanks very much.

Short answer: can’t be done. Long answer: search this list for the long
discussions about the numerous ways in which it can’t be done.

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of timixu
Sent: Thursday, August 24, 2006 8:00 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to improve the performance of virtual
scsi miniport disk?

Hi everyone.
I write a virtual scsi miniport disk. It use file to store
data. But the performance is bad. Just about 1.0MB/s, the
real hard disk is 50.0MB/s. Is there one appropriate way to
improve the transfer speed.
Thanks very much.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online
at http://www.osronline.com/page.cfm?name=ListServer

This has been discussed so many times on this mail list. Please search
the archive. You can find out some *hack skill* to boost your performance.


Best Regards,
hanzhu

timixu дµÀ:

Hi everyone.
I write a virtual scsi miniport disk. It use file to store data. But the
performance is bad. Just about 1.0MB/s, the real hard disk is 50.0MB/s. Is
there one appropriate way to improve the transfer speed.
Thanks very much.


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

You can achieve high speeds with a virtual scsi miniport. I’ve seen >400MB/sec. If you are doing scsiport context switching, perhaps the method is not well designed. Or it could be something with the parameters to open or write to the file. If you shed some light on how you are doing these things, perhaps people can identify what might be the problem.

eof

Thanks for reply.
I use the “Srb process thread” and “Request complete timer” model. In
HwStartIo routine, I insert the srb to a request list
(ExInterlockedInsertTailList). The “Srb process thread” process these
srb(s) and insert the completed srb request to anthor list. The “Request
complete timer” check the list and complete this srbs( use
ScsiPortNotification with NextRequest and RequestComplete ), The timer is
start by ScsiPortNotification( RequestTimerCall,…).

I think this model is easy to understand. I hope my poor Enlisgh
describe it clearly. :).

I open image file in this way.

status = ZwCreateFile( &hImageFile,
GENERIC_READ | GENERIC_WRITE,
&ObjectAttributes,
&IoStatus,
NULL,
FILE_ATTRIBUTE_NORMAL,
0,
FILE_OPEN,
FILE_NON_DIRECTORY_FILE |
FILE_RANDOM_ACCESS |
FILE_NO_INTERMEDIATE_BUFFERING |
FILE_SYNCHRONOUS_IO_NONALERT,
NULL,
0
);

But I can not understand these concept “scsiport context switching”.
Where can I find document about this.

Thanks a lot!

Your English is just fine I think. Scsiport context means your code is called from scsiport and thus can safely call any scsiport function. You are not on scsiport context when your thread is running and cannot call scsiport functions. You use the timer to get back on scsiport context (note there are other better ways, though complex). However, you can dramatically increase your write performance with your existing model. Implement “write back” cacheing. Validate and complete the write SRB’s immediately inside StartIo, then do the actual data write in the background with your thread. The only architectural difference between that and how it works right now is when you complete the SRB. What you want to do to make this perfectly legal is set CachesData=TRUE in FindAdapter and when you get a SRB_FUNCTION_FLUSH is to wait for all your background writes to complete. That should really fly after you do it!

eof

HaHa. Thank you “regserver”. I can not help laugh.
The WRITE speed reach 1500MB/s. :slight_smile:

Bug I found some problems.
After I reboot system, the previous write data losed. I only save the
write data buffer pointer “Srb->DataBuffer”. Should I save a copy of
“Srb->DataBuffer”.
The READ speed is also 1.0MB/s. I think the key of performance is how
to complete the Srb(s) more quickly. Is there anthor way that complete the
Srb(s), but Do not use Scsiport Timer.

You cannot access the write buffer or anything else in the SRB after completing it. The first way to overcome this with a write back cache is simply to double buffer. That is, dynamically allocate & copy in StartIo and dynamically free when your background write finishes. A second method is to use a high quality buffer manager where each of your write buffers couples as a read cache for even greater performance. A third solution to high performance writes involves eliminating double buffering completely and is related to your other question on read performance (see below).

To get good read performance, you can’t use a 10ms timer to poll for completion; that is just too slow. You need a fast context switch from your thread back to scsiport context with microsecond resolution so you can complete each request lightning quick. This also alleviates the need to double buffer writes or do write back caching and still get good performance. The MiniFile source code pioneers a fast and clean context switching method. The sample code also utilizes asynchronous file i/o calls which allows even greater performance tuning.

http://www.perisoft.net/miniport/index.htm

eof

Thank you “regserver”. You help me so many times.
Now I know the key on how to improve performance.
The “minifile” source code costs $6000, It seems
the source code cost $3000 just a few days ago :).
But no matter $6000 or $3000, I think my boss will
not agree to buy it. He think it is so expensive.
For me, $3000 is the salary for one year.
Thank you again.

They did not include any EULA restricting reverse engineering. So get the
binary they put for public download load IDA and disassemble that *HUGE* 5K
miniport (most of it is EXE file header anyway). Now you have two ways to
go: 1) understand how it works 2) go look for other job…

Anton

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of timixu
Sent: Friday, September 01, 2006 3:21 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] How to improve the performance of virtual scsi miniport
disk?

Thank you “regserver”. You help me so many times.
Now I know the key on how to improve performance.
The “minifile” source code costs $6000, It seems
the source code cost $3000 just a few days ago :).
But no matter $6000 or $3000, I think my boss will
not agree to buy it. He think it is so expensive.
For me, $3000 is the salary for one year.
Thank you again.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer