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

Use platform-specific methods for FileAccess reading and writing #84107

Merged

Conversation

BlueCube3310
Copy link
Contributor

@BlueCube3310 BlueCube3310 commented Oct 28, 2023

Implements platform-specific variants of FileAccess's get_16, get_32, get_64, store_16, store_32, and store_64. Also adds MSVC-specific versions of BSWAPxx functions.

This results in a significant performance gain when reading or writing large amounts of binary data: ~5x faster writing and ~6x faster reading.

Benchmark results for writing data to a file:

Windows x64, build - production

data master PR
10000000 x uint64_t (78 mb) 1.70s 0.30s
50000000 x uint64_t (390 mb) 8.70s 1.80s
10000 x uint64_t (79 kb) 0.0020s 0.0007s
500000 x uint64_t big endian (4 mb) 0.085s 0.015s
500000 x uint64_t little endian (4 mb) 0.086s 0.015s

A small project for testing whether the changes work correctly: file_access_test.zip

Progress:

  • FileAccessWindows
  • FileAccessUnix
  • FileAccessAndroid
  • Minimal testing project

@BlueCube3310 BlueCube3310 force-pushed the file-access-optimization branch 5 times, most recently from ec4108b to 6b2cf48 Compare October 29, 2023 16:32
@BlueCube3310 BlueCube3310 marked this pull request as ready for review October 31, 2023 16:39
@BlueCube3310 BlueCube3310 requested review from a team as code owners October 31, 2023 16:39
Copy link
Contributor

@m4gr3d m4gr3d left a comment

Choose a reason for hiding this comment

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

The Android section looks good!

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Nov 1, 2023
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally on Linux, it works as expected. Saved file checksums are identical to before with the test project.

@akien-mga akien-mga merged commit 5d44c85 into godotengine:master Jan 4, 2024
15 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

None yet

7 participants