[tarantool-patches] Re: [PATCH v2] core: Non-blocking io.popen

Stanislav Zudin szudin at tarantool.org
Mon Jun 3 18:53:23 MSK 2019



On 31.05.2019 20:32, Konstantin Osipov wrote:
> * Vladimir Davydov <vdavydov.dev at gmail.com> [19/05/31 16:01]:
>>> +static struct popen_data *
>>> +popen_lookup_data_by_pid(pid_t pid)
>>> +{
>>> +	struct popen_data *cur = popen_data_list;
>>> +	for(; cur; cur = cur->next) {
>>> +		if (cur->pid == pid)
>>> +			return cur;
>>> +	}
>>
>> Please write a comment explaining why you think linear search is fine
>> here and why we don't use some kind of hash or tree.
> 
> If it is a list of all popen processes, please avoid.
> We can't afford adding a yet another, even unlikely, reason for a
> 100% hog. This makes support difficult - keeping them all one's
> head and checking neither is triggered.
> 

How many simultaneously running popen processes do you expect? I believe
it's tens, not even hundreds.
In this case the hash won't give any noticeable performance improvement
in comparison with the list.
The newly created process is being put in the head of the list.
It's O(1).
The O(N) occurred only in the SIGCHLD handler and in the finalizer.




More information about the Tarantool-patches mailing list