Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce file opening #11764

Closed
wants to merge 2 commits into from
Closed

Reduce file opening #11764

wants to merge 2 commits into from

Conversation

rouault
Copy link
Member

@rouault rouault commented Jan 30, 2025

  • CPLGetPhysicalRAM(): cache result to avoid multiple file openings on repeated calls
  • /vsis3/: cache content of ~/.aws/config and ~/.aws/credentials to avoid multiple file openings on repeated calls

Helps reducing the number of openat() syscalls in MapServer intensive scenarios

@rouault rouault added this to the 3.11.0 milestone Jan 30, 2025
@rouault rouault force-pushed the reduce_file_opening branch 2 times, most recently from 14640f3 to 567a057 Compare January 30, 2025 21:19
@coveralls
Copy link
Collaborator

coveralls commented Jan 30, 2025

Coverage Status

coverage: 70.06% (-0.002%) from 70.062%
when pulling a10e239 on rouault:reduce_file_opening
into daa1b67 on OSGeo:master.

@rouault rouault force-pushed the reduce_file_opening branch from 567a057 to a10e239 Compare January 30, 2025 21:35
static std::mutex goMutex;
std::lock_guard oGuard(goMutex);

// Cache last request and result to avoid repeated file accesses.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the credentials cache fromosCredentialsFilenamecache populated once at process start and never again? Users could (should) update the value periodically, so a long-running GDAL processes might get access denied from AWS but it's possible new credentials were updated in the file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the credentials cache from osCredentialsFilename cache populated once at process start and never again?

yes

but it's possible new credentials were updated in the file.

is it really realistic that ~/.aws/config or ~/.aws/credentials content change during the lifetime of a process ? Aren't those used for 'static' credentials ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it really realistic that ~/.aws/config or ~/.aws/credentials content change during the lifetime of a process ? Aren't those used for 'static' credentials ?

The typical GDAL user would probably not rotate credentials in the lifetime of a process (such as in a single gdalwarp call). However, some companies/AWS IAM policies require users to rotate static credentials every few hours. My particular use case (long-running Mapserver) is probably an edge case where it's easy enough for me to restart a Mapserver FastCGI process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so this basically means that the whole idea is busted. I'll revert that commit and just keep the CPLGetPhysicalRAM() change

@rouault
Copy link
Member Author

rouault commented Jan 31, 2025

closing that one, and just keeping the CPLGetPhysicalRAM() change in #11764

@rouault rouault closed this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants