tarantool / tarantool/tarantool

popen: optimize inherited fds closing

Open
#5,045 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

optimization popen
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

Tarantool version: 2.5.0-62-gbb7c3d167.

Note that it is much faster to simply try setting the flag on all
possible descriptors, than to try and find out which descriptors are
actually open. (The latter is possible in Linux via e.g.
/proc/self/fd/.)

https://stackoverflow.com/a/21952155/1598057

We need to verify whether the proposed approach with fcntl(fd, F_SETFD, FD_CLOEXEC); on fds from 3 to 4096 is actually faster then reading /proc/self/fd and closing everything that we're found.

How about closing everything from 3 to 4096 without reading /proc/self/fd?

Let's measure and decide whether it worth to change anything.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the popen implementation and compare the current inherited-file-descriptor handling with the two approaches described: reading /proc/self/fd or applying fcntl(fd, F_SETFD, FD_CLOEXEC) from descriptor 3 through 4096. Measure both approaches and document which is faster and whether the implementation should change.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux
Domain
operating-systems
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.