Jonathan Adams wrote:
> On Mar 12, 2008, at 3:20 AM, Sophie Hu wrote:
>> I am doing a project, in which 10k users set up connection with one  
>> server.
>> The server part is originally implemented using select() mode. Since  
>> it consumed a lot of CPU, I replaced select() mode with port_getn().  
>> Unfortunally, the CPU consumption is not reduced at all. I am trying  
>> to analyze the reason:
>>
>> To use select(), you have to store all the interested sockets in an  
>> array or list. Then you check each element of the array/list to see  
>> if any of them is ready to read/write (using FD_ISSET).
>>
>> By using port_getn(), you already get the sockets which are ready to  
>> read/write from the eventList.  Therefore, you just read/write data  
>> from/to the sockets in the eventList (event. portev_object), you do  
>> not need to search the whole array/list to find the sockets.
>>
>> However, in my case, each time I get eventList from port_getn(), I  
>> still need to search the while array/list to get some other client  
>> information based on socketID I get from eventList. Due to this  
>> reason, I did not get benefit from port_getn() and CPU is not  
>> reduced. Is my analysis correct?
> 
> Sophie,
> 
> You shouldn't need to do a search;  ports allow you to associate a  
> pointer with each event of interest which you can use directly.  You  
> should pass the pointer to your client information as the "user"  
> argument to port_associate(), and it will be sent in the portev_user  
> field of the port_event_t structure port_getn() fills in.
> 
> See if that helps.
> 
> Cheers,
> - jonathan
> 
> --------------------------------------------------------------------------
> Jonathan Adams, Sun Microsystems, ZFS Team    http://blogs.sun.com/jwadams
> 
> _______________________________________________
> perf-discuss mailing list
> perf-discuss@opensolaris.org

Indeed - for a working example, see my blog entry from
2004:

  http://blogs.sun.com/barts/entry/entry_2_event_ports

- Bart

-- 
Bart Smaalders                  Solaris Kernel Performance
[EMAIL PROTECTED]               http://blogs.sun.com/barts
"You will contribute more with mercurial than with thunderbird."
_______________________________________________
perf-discuss mailing list
perf-discuss@opensolaris.org

Reply via email to