refactor: modularization and performance#5
Merged
paulocoghi merged 8 commits intoJul 20, 2026
Merged
Conversation
…olders and splitted
paulocoghi
deleted the
refactor/modularization--performance-optimizations--memory-allocations
branch
July 20, 2026 19:55
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.
This PR is focused on better organizing the codebase and applying some initial performance and efficiency optimizations.
Architectural Changes
Mongo::ClientandMongo::Collectionwere split into their respective subfolders and multiple smaller modules likeclient/retryable_writes.cr,collection/find_and_modify.cr.spec/unified_runner.crwas split into multiple modules atspec/unified/, introducing a cleanDispatcherpattern that makes it a lot easier to expand and improve the driver.Performance & Memory Optimizations (reduced allocations)
read_fullywithIO::Memoryjgaskins/pipeinstead of kernel-levelIO.pipe. This has the potential to bring up to ~10x faster pipe throughput.Mutexfor trackingrequest_ids with a lock-freeAtomic(Int32)..map/.selectarray materialization, switching to single-passcompact_mapandString.build.Crystal 1.20/1.21 Modernization & Safety
.not_nil!: All instances of.not_nil!have been removed. The driver relies entirely on Crystal's type narrowing and raises descriptiveMongo::Errors if anomalies occur.Sync::Mutexand removed all assumptions of single-thread fiber pinning, making the driver robust for Crystal 1.21Parallelcontexts.Test Status: 324/324 Unified Test Format examples correctly passing (18m 55s execution time)