Skip to content

Improve c sharp db storage#2

Merged
MaxAkbar merged 55 commits intomainfrom
Improve_CSharpDB_Storage
Mar 4, 2026
Merged

Improve c sharp db storage#2
MaxAkbar merged 55 commits intomainfrom
Improve_CSharpDB_Storage

Conversation

@MaxAkbar
Copy link
Owner

@MaxAkbar MaxAkbar commented Mar 4, 2026

Summary

Major storage engine refactoring, query execution performance optimizations, new CSharpDB.Storage.Diagnostics package, CI/CD infrastructure, and per-package NuGet README documentation. 169 files changed (~19.8K lines added).

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactor / maintenance
  • Tests only

Related Issues

N/A

Testing

  • dotnet build CSharpDB.slnx
  • Relevant tests executed
  • Manual verification performed (if applicable)

New test suites: CheckpointPolicyTests, IndexCursorTests, PageCacheTests, StorageDeviceAndChecksumTests, StorageDiagnosticsTests, StorageEngineExtensibilityTests. New benchmarks: WalCoreBenchmarks, SqlTextStabilityBenchmarks, SystemCatalogBenchmarks, TriggerDispatchBenchmarks, ScanBenchmarks.

Checklist

  • I followed the project style and conventions.
  • I added or updated tests for behavior changes.
  • I updated docs for user-facing changes.
  • I verified no sensitive data was added.

Notes for Reviewers

  • Storage engine has been reorganized into subsystem folders (BTree/, Caching/, Catalog/, Paging/, Wal/, etc.) — large diff but no behavioral changes from the restructure itself
  • New CSharpDB.Storage.Diagnostics package added with read-only inspection tools
  • WAL batch commit path and PK fast-path lookups are the biggest perf wins
  • Per-project NuGet READMEs replace the shared root README for package publishing
  • CI, release, and perf-guardrail GitHub Actions workflows added

MaxAkbar added 30 commits March 1, 2026 00:07
…lity

- Introduced models for database inspection options, reports, and integrity issues.
- Implemented the WalInspector class to inspect WAL files, including validation of headers and frames.
- Added tests for various inspection scenarios, including missing WAL files and integrity checks.
- Updated project references to include the new diagnostics module.
…tions

- Updated SystemCatalogTests to pass cancellation token to database operations.
- Updated WalTests to pass cancellation token to database operations.
- Ensured all async calls in tests are properly handling cancellation tokens for better control over test execution.
…ema, and TriggerSchema

- Added SchemaSerializer for serializing and deserializing TableSchema and IndexSchema to/from byte arrays.
- Introduced Varint class for variable-length integer encoding.
- Created DefaultStorageEngineFactory to manage storage engine components.
- Defined IStorageEngineFactory interface for storage engine creation.
- Implemented StorageEngineContext to hold references to storage engine components.
- Added StorageEngineOptions for configuring storage engine behavior.
- Introduced IClock interface and SystemClock implementation for time-based policies.
- Developed TransactionCoordinator for managing transaction state and write-lock lifecycle.
- Created IWriteAheadLog interface and WriteAheadLog class for write-ahead logging.
- Implemented WalIndex for tracking committed frames in the WAL.
- Added tests for serialization and varint functionality.
… interceptor support

- Added `IPageChecksumProvider` interface and `AdditiveChecksumProvider` implementation for customizable checksum calculations in WAL.
- Introduced `IPageOperationInterceptor` interface and `CompositePageOperationInterceptor` for handling lifecycle events during page operations.
- Updated `Pager` and `PageBufferManager` to utilize interceptors for read/write operations, commits, checkpoints, and recovery.
- Enhanced `StorageEngineOptions` to include a checksum provider and interceptors, with a builder pattern for configuration.
- Created tests to validate the functionality of custom checksum providers and the behavior of interceptors during various database operations.
- Refactored `WriteAheadLog` to use the new checksum provider for frame and header verification.
Refactor WAL commit and read logic for fewer allocations and faster commit path.
Improve AdditiveChecksumProvider with SIMD for checksum calculation.
Use Buffer.BlockCopy for slotted page pointer shifts.
Simplify page cache fetch logic.
Add advanced benchmark diagnoser and support for --filter option.
Remove redundant varint header length code in BTree.
- Introduced deferred checkpoint requests in CheckpointCoordinator to handle scenarios where checkpoints are requested while readers are active.
- Updated ReleaseReaderSnapshot to prevent negative active reader counts.
- Modified ShouldCheckpoint logic to set deferred checkpoint requests based on active readers and committed frame counts.
- Implemented TryConsumeDeferredCheckpointRequest and ClearDeferredCheckpointRequest methods for managing deferred checkpoints.
- Added MaxWalBytesWhenReadersActive option in PagerOptions to limit WAL growth when readers are active, preventing excessive WAL size.
- Enhanced WriteAheadLog to handle exceptions more gracefully during WAL operations, ensuring robust error handling.
- Updated tests to validate the behavior of deferred checkpoints and WAL backpressure limits under various scenarios.
- Removed IBTreeIndexStore interface as it is no longer needed, simplifying the index store implementations.
…mary key lookups and enhancing statement caching
…ual predicates and optimizing query planner logic
…ove performance and reduce unnecessary cloning
…eate detailed documentation for storage improvements
…idual predicate handling and removing unnecessary row ownership checks in QueryResult
…ount support and improve row buffer handling
MaxAkbar added 23 commits March 2, 2026 20:13
- Introduced `perf-thresholds.json` to define performance thresholds for various benchmarks.
- Created `perf-guardrails-last.md` to summarize benchmark results against the defined thresholds.
- Implemented `Capture-Baseline.ps1` to capture baseline performance metrics for specified benchmarks.
- Added `Compare-Baseline.ps1` script to compare current benchmark results against the baseline and generate a report.
- Developed `Run-Perf-Guardrails.ps1` to orchestrate the benchmarking process and report generation.
- Enhanced benchmark filtering to include additional benchmarks in the performance guardrails.
… page cache, and storage device functionality
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad2dda682c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@MaxAkbar MaxAkbar merged commit 8a5301e into main Mar 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant