Conversation
…t, and documentation This commit implements several code quality improvements: **Error Handling:** - Add ReadOnlyError exception for write attempts with descriptive messages - Add DuplicatePathError exception to prevent duplicate file paths - Replace generic string errors with properly typed exceptions **Resource Management:** - Implement close() and closed?() methods following IO conventions - Add block form to get/get? for automatic resource cleanup - Add finalize for garbage collection safety - Validate file state before operations **Thread Safety:** - Create new BakedFile instances on each get() call - Ensures independent state per caller, preventing conflicts **Code Quality:** - Refactor StringEncoder to use readable character literals - Replace magic numbers with self-documenting code **Documentation:** - Add comprehensive architecture documentation to BakedFile class - Document rewind recreation logic with performance implications - Explain design decisions and alternatives considered - Add detailed method documentation **Testing:** - Add tests for write protection and error messages - Add tests for close functionality and block forms - Add tests for duplicate path detection - All tests passing These improvements enhance maintainability, thread safety, and developer experience while maintaining backward compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add baseline and baked benchmark applications to measure BakedFileSystem performance compared to traditional File I/O. - Baseline app: simple Kemal server with File I/O (baseline.cr, 8 lines) - Baked app: Kemal server with BakedFileSystem (baked.cr, 16 lines) - Shared test assets: small.txt (1.1KB), medium.json (170KB), large.dat (1MB) - Add .gitignore to exclude binaries, debug files, and dependencies Both apps are minimal single-file implementations serving files on /files/:name endpoint for accurate benchmarking.
Implements complete benchmarking framework for BakedFileSystem: TASK.38.3: Compile Time Benchmarking - compile_time.cr: Measures compilation overhead - Runs 5 iterations for statistical validity - Outputs results/compile_time.json TASK.38.4: Binary Size Analysis - binary_size.cr: Analyzes binary size and compression - Calculates overhead factor and compression ratio - Outputs results/binary_size.json TASK.38.5: Memory Usage Benchmarking - memory.cr: Profiles RSS at various stages - Measures startup, file access, and post-GC memory - Outputs results/memory.json TASK.38.6: Performance Benchmarking - performance.cr: Measures latency and throughput - Tests small/medium/large files - 1000 requests with 10 concurrent clients - Outputs results/performance.json TASK.38.7: Report Generator - report_generator.cr: Aggregates all results - Generates comprehensive markdown report - Includes tables, ASCII charts, and conclusions - Outputs results/REPORT.md Supporting Files: - run_all.sh: Master script to run all benchmarks - README.md: Complete usage documentation - .gitignore: Excludes JSON/MD results from git All scripts properly handle: - Process error capture - Server lifecycle management - Port cleanup - Statistical analysis - Cross-platform compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Process#pid returns Int64, so get_rss_mb must accept Int64 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Replace all numeric sleep calls with Time::Span: - sleep 0.1 → sleep 0.1.seconds - sleep 1 → sleep 1.second - sleep 2 → sleep 2.seconds - sleep WARMUP_DELAY → sleep WARMUP_DELAY.seconds Fixes Crystal 1.17+ deprecation warnings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive Benchmarks section with: - Link to benchmarks/README.md for details - System specifications - Compile time: +3.7s (30% overhead) - Binary size: 0.88x compression ratio - Memory: minimal overhead with lazy decompression - Performance: comparable latency/throughput - Clear recommendations on when to use BakedFileSystem Provides users with objective performance data to make informed decisions about using BakedFileSystem. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive compile-time size validation with configurable limits: - New Stats class tracks total and per-file compressed sizes - ByteCounter IO wrapper for accurate size tracking during encoding - Environment variables for global configuration: - BAKED_FILE_SYSTEM_MAX_SIZE (default: 50MB) - BAKED_FILE_SYSTEM_WARN_THRESHOLD (default: 10MB) - Per-folder max_size parameter for granular control - Large file warnings (>1MB compressed) - Clear error messages with actionable guidance - Comprehensive test coverage for all validation scenarios - Examples demonstrating warnings and size limit enforcement Breaking change: Builds may fail if embedded files exceed default 50MB limit. Configure via environment variable or max_size parameter to override.
BREAKING CHANGE: Compile-time size validation now enforced This release introduces automatic size validation for embedded files with a default maximum of 50MB compressed. Builds will fail at compile-time if this limit is exceeded. Migration options: - Environment variable: BAKED_FILE_SYSTEM_MAX_SIZE=<bytes> - Per-folder parameter: bake_folder "./assets", max_size: <bytes> See CHANGELOG.md for detailed migration guide. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Sija
reviewed
Nov 8, 2025
Comment on lines
306
to
321
| def self.add_baked_file(file : BakedFileSystem::BakedFile) | ||
| if @@paths.includes?(file.path) | ||
| raise BakedFileSystem::DuplicatePathError.new("Duplicate file path: #{file.path}. File already baked.") | ||
| end | ||
| @@paths << file.path | ||
| @@files << file | ||
| end | ||
|
|
||
| def self.add_baked_file(file : BakedFileSystem::BakedFile) | ||
| if @@paths.includes?(file.path) | ||
| raise BakedFileSystem::DuplicatePathError.new("Duplicate file path: #{file.path}. File already baked.") | ||
| end | ||
| @@paths << file.path | ||
| @@files << file | ||
| end | ||
| end |
Sija
reviewed
Nov 8, 2025
Comment on lines
+62
to
+67
| private def human_size(bytes : Int64) : String | ||
| return "#{bytes} B" if bytes < 1024 | ||
| return "#{(bytes / 1024.0).round(1)} KB" if bytes < 1024 * 1024 | ||
| return "#{(bytes / (1024.0 * 1024)).round(1)} MB" if bytes < 1024 * 1024 * 1024 | ||
| "#{(bytes / (1024.0 * 1024 * 1024)).round(1)} GB" | ||
| end |
Contributor
There was a problem hiding this comment.
There's already Number#humanize for this use case.
Comment on lines
+70
to
+73
| value = ENV[var_name]? | ||
| return nil unless value | ||
|
|
||
| value.to_i64? |
Contributor
There was a problem hiding this comment.
Can be shortened to:
Suggested change
| value = ENV[var_name]? | |
| return nil unless value | |
| value.to_i64? | |
| ENV[var_name]?.try(&.to_i64?) |
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.
Problem
BakedFileSystem had no mechanism to prevent accidentally embedding huge files that bloat binary size. Users could unknowingly create multi-hundred-megabyte binaries without any warnings or feedback during compilation.
Solution
Implemented comprehensive compile-time size validation with configurable limits (TASK.6):
BAKED_FILE_SYSTEM_MAX_SIZEandBAKED_FILE_SYSTEM_WARN_THRESHOLDmax_sizeparameter for granular limitsBreaking Change
Migration options:
Changes
New Files
src/loader/stats.cr- Size tracking and validation logicsrc/loader/byte_counter.cr- IO wrapper for accurate byte countingexamples/- Working demonstrations of validation featuresCHANGELOG.md- Comprehensive changelog with migration guideModified Files
src/baked_file_system.cr- Addedmax_sizeparameter tobake_foldermacrosrc/loader.cr- Parse max_size from command-line argumentssrc/loader/loader.cr- Integrated size tracking and reportingspec/loader_spec.cr- 174 new lines of comprehensive test coverageREADME.md- Added "Size Management & Limits" documentationshard.yml- Version bump to 0.12.0src/baked_file_system/version.cr- Version bump to 0.12.0Test Coverage
Other
Version Strategy
Following SemVer for pre-1.0 releases where breaking changes bump MINOR version:
Release Assets
v0.12.0(pushed)Why This Change?
See CHANGELOG.md for complete release notes and migration guide.