implement open file cache #596

merged 3 commits into from Nov 23, 2015


None yet
1 participant

kazuho commented Nov 18, 2015

For devices using 10ge connection but not-so-powerful CPU serving static files, the cost of open(2) and close(2) becomes an issue.

Implementing an in-memory cache is one way to address the issue, but doing so does consume memory and therefore cannot be enabled by default.

OTOH a file descriptor cache that shares a file descriptor only when a file is opened more than once is a good approach for the following reasons:

  • reduces the number of open(2) / close(2) being called
  • MAY reduce the number of files opened at the same time

The cache implemented by this PR also have following characteristics:

  • file descriptor cache is freed every once the event loop
  • the maximum entries kept open by the file desriptor cache is 2x the max. concurrency of HTTP/2 connection

relates to: #139

@kazuho kazuho added the enhancement label Nov 18, 2015

@kazuho kazuho added this to the v1.6 milestone Nov 18, 2015

kazuho added a commit that referenced this pull request Nov 23, 2015

@kazuho kazuho merged commit 3d3505e into master Nov 23, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
continuous-integration/travis-ci/push The Travis CI build passed

This comment has been minimized.

Show comment
Hide comment

kazuho Nov 24, 2015


cab8a98 fixes a regression in this PR (i.e. #596), not #595.


kazuho commented Nov 24, 2015

cab8a98 fixes a regression in this PR (i.e. #596), not #595.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment