Repository navigation
sas7bdat: write 64KB pages by default - #417
Merged
Merged
Conversation
Modern SAS selects page sizes of 8-64KB depending on observation length (with 64KB typical on current Windows/UNIX releases), while ReadStat has hardcoded a 4KB default inherited from older 32-bit Windows conventions. Larger pages reduce per-page overhead when reading and writing large files (16x fewer page seeks/reads) and match what SAS itself produces today.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
馃 Written by AI 馃
ReadStat hardcodes a 4KB page size when writing sas7bdat files, a convention dating from 32-bit Windows SAS. Modern SAS chooses the page size at file-creation time based on observation length, engine, and OS, and in practice lands on 8-64KB:
Writing 64KB pages matches what modern SAS produces and reduces per-page overhead 16x on large files (fewer page reads/seeks for readers, less page-header bookkeeping for writers). ReadStat's reader already accepts page sizes up to 16MB, so files written with this change remain readable by older ReadStat versions, and SAS itself supports 64KB pages natively.
Tested by round-tripping a 2M-row dataset through ReadStat's sas7bdat writer and reader: the written file has a 65536-byte page size and reads back identically. (Note:
make check'stest_readstatsegfaults immediately on macOS arm64 both with and without this change, so I couldn't use it for validation.)