HomePhabricator

Skip creating parent directories when accessing a file in read-only mode from…

Description

Skip creating parent directories when accessing a file in read-only mode from filesystem

Summary:
When reading a file on disk, we expect to fail if the file is not found. We can safely skip creating the parent directories in this case since we won't create the file anyway (this requires a write access).
This create_directories call involves 2 syscalls (on Linux) per call and is about 30% of the time spent in the FlatFile::Open() method. This diff is an easy optimization that can boost the access requiring lots of reads, like the listunspent RPC or the various chronik history endpoints.

Test Plan:
With Chronik:

ninja all check-all

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D18281

Details

Provenance
FabienAuthored on Jun 23 2025, 09:19
FabienPushed on Jun 23 2025, 14:42
Reviewer
Restricted Project
Differential Revision
D18281: Skip creating parent directories when accessing a file in read-only mode from filesystem
Parents
rABC3b910b70af07: [Automated] Update seeds
Branches
Unknown
Tags
Unknown