Skip to content

Optimize java.io.UnixFileSystem to avoid ErrnoException churn.#2762

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_922403915
Open

Optimize java.io.UnixFileSystem to avoid ErrnoException churn.#2762
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_922403915

Conversation

@copybara-service
Copy link
Copy Markdown

Optimize java.io.UnixFileSystem to avoid ErrnoException churn.

Replace Libcore.os.access with Libcore.os.canAccess in UnixFileSystem.checkAccess().

Libcore.os.access throws ErrnoException on failure (e.g. when a file does not exist), which must be caught and handled. On iOS, throwing ObjC exceptions has a significant performance cost (stack unwinding, runtime locks) and also litters "Earlier exception" logs in Crashpad/Breakpad crash reports, obscuring real errors.

Libcore.os.canAccess performs the same POSIX access check but returns a boolean (false on failure) without throwing any exceptions, completely eliminating the exception churn for File.exists(), File.canRead(), and File.canWrite() checks that return false.

Replace Libcore.os.access with Libcore.os.canAccess in UnixFileSystem.checkAccess().

Libcore.os.access throws ErrnoException on failure (e.g. when a file does not exist), which must be caught and handled. On iOS, throwing ObjC exceptions has a significant performance cost (stack unwinding, runtime locks) and also litters "Earlier exception" logs in Crashpad/Breakpad crash reports, obscuring real errors.

Libcore.os.canAccess performs the same POSIX access check but returns a boolean (false on failure) without throwing any exceptions, completely eliminating the exception churn for File.exists(), File.canRead(), and File.canWrite() checks that return false.

PiperOrigin-RevId: 922403915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant