Repository navigation
Resolve the table path once and suppress the finalizer on Close - #342
Merged
Merged
Conversation
Opening a table by relative path resolved the current directory six times (File.Exists, the FileStream open and four memo-file checks). Each lookup costs about 10 us on macOS, which made opening a small table by relative path far slower than by absolute path. The path is now resolved once and reused. DbfTable.Close called Dispose(true) directly, so the finalizer was never suppressed and every closed table was promoted to the next GC generation. Close now goes through Dispose(). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
chrisrichards
added a commit
that referenced
this pull request
Nov 23, 2026
…#343) Since #342 the table path is resolved with Path.GetFullPath before the existence check, so a null path throws ArgumentNullException and an empty path or one containing a NUL character throws ArgumentException. Previously all three were reported as FileNotFoundException. The new exceptions match File.OpenRead and FileStream and describe the problem better, so the tests now state them as the intended behaviour. A path to a file that does not exist still throws FileNotFoundException. Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This was referenced Nov 23, 2026
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.



Why
The cross-library benchmark shows Sylvan about 19% ahead of DbfDataReader (280 us vs 351 us). That gap is not in the read path: the benchmark opens the fixture by relative path, and
DbfTable(string path)resolved the current directory six times per open (File.Exists, theFileStreamopen, and four memo-fileFile.Existschecks). Each lookup costs about 10 us on macOS. Sylvan is handed a stream from a singleFile.OpenRead.BenchmarkDotNet (short job, 2.3.1 package, .NET 10.0.15, M3 Max):
Changes
DbfTable(string path)callsPath.GetFullPathonce and uses the result for the existence check, theFileStreamand the memo lookup. ThePathproperty andMemoPath()return the same values as before.DbfTable.Close()callsDispose()instead ofDispose(true), so the finalizer is suppressed. Previously every closed table was still finalized and promoted, which is why the benchmark showed Gen1 9.8 / Gen2 0.5 collections per 1000 operations against Sylvan's 1.0 / 0.Measured
Stopwatch harness against this branch (not BenchmarkDotNet):
The saving is a fixed cost per open, so it matters for small tables and is negligible for large ones.
The repo benchmark has not been re-run against this change: it reads the published package, so that needs a release or a local pack.
Testing
dotnet test -c Release: 535 passed, 1 skipped (already skipped on main).🤖 Generated with Claude Code