diff --git a/docs/features.md b/docs/features.md index b9fd8f4..b2f8a31 100644 --- a/docs/features.md +++ b/docs/features.md @@ -44,6 +44,7 @@ - Status: completed - Description: Explicit synchronization and concurrent collections - Last Update: 2025-05-11 +- Updated By: Stan44 ## spatial_interfaces - Status: completed @@ -55,6 +56,11 @@ - Description: Parallel processing of chunks based on spatial queries and regions - Last Update: 2025-05-11 +## feature_tracking +- Status: completed +- Description: Track feature statuses +- Last Update: 2025-05-11 + ## priority_loading - Status: in_progress - Description: Prioritized chunk loading system (partially implemented) @@ -62,12 +68,12 @@ ## dependency_tracking - Status: in_progress -- Description: Dependency-aware disposal logic +- Description: Dependency-aware disposal logic (Partially Implemented) - Last Update: 2025-05-10 ## dispose_pattern - Status: in_progress -- Description: Full dispose pattern with finalizers for unmanaged resources +- Description: Full dispose pattern with finalizers for unmanaged resources (Partially Implemented) - Last Update: 2025-05-10 ## exception_handling @@ -82,29 +88,19 @@ ## progress_tracking - Status: in_progress -- Description: Track progress and auto-update status documents (mostly implemented) -- Last Update: 2025-05-10 +- Description: Track progress and auto-update status documents (mostly implemented kinda still manual...) +- Last Update: 2025-05-11 ## git_integration - Status: in_progress -- Description: Parse Git logs for status updates (partially implemented) -- Last Update: 2025-05-10 - -## feature_tracking -- Status: in_progress -- Description: Track feature statuses (partially implemented) -- Last Update: 2025-05-10 +- Description: Parse Git logs for status updates (partially implemented testing with this push.) +- Last Update: 2025-05-11 ## doc_generation - Status: in_progress - Description: Auto-generate status docs and changelog (partially implemented) - Last Update: 2025-05-10 -## todo_management -- Status: in_progress -- Description: Automate updates based on code reviews and commits -- Last Update: 2025-05-10 - ## dependency_interfaces - Status: planned - Description: Interface-level dependency methods diff --git a/docs/status/ChunkManager-Status.md b/docs/status/ChunkManager-Status.md index b534484..4a6458e 100644 --- a/docs/status/ChunkManager-Status.md +++ b/docs/status/ChunkManager-Status.md @@ -2,6 +2,51 @@ Last updated: 2025-05-11 +## Code Statistics + +Total lines of code: **7331** + +Number of source files: **34** + +### All Files by Line Count + +| File | Lines | Path | +|------|------:|------| +| SpatialChunkIndex.cs | 1228 | src/AdvChkSys\Spatial\SpatialChunkIndex.cs | +| ChunkLoadingPriority.cs | 677 | src/AdvChkSys\Loading\ChunkLoadingPriority.cs | +| ChunkThreadingExtensions.cs | 380 | src/AdvChkSys\Threading\ChunkThreadingExtensions.cs | +| ChunkManager2D.cs | 313 | src/AdvChkSys\Manager\ChunkManager2D.cs | +| ChunkDependencyTracker.cs | 310 | src/AdvChkSys\Dependencies\ChunkDependencyTracker.cs | +| ChunkTaskScheduler.cs | 310 | src/AdvChkSys\Threading\ChunkTaskScheduler.cs | +| ChunkThreadingManager.cs | 281 | src/AdvChkSys\Threading\ChunkThreadingManager.cs | +| ChunkOperationQueue.cs | 274 | src/AdvChkSys\Threading\ChunkOperationQueue.cs | +| ChunkThreadingDiagnostics.cs | 273 | src/AdvChkSys\Threading\ChunkThreadingDiagnostics.cs | +| ChunkThreadingPerformanceMonitor.cs | 257 | src/AdvChkSys\Threading\ChunkThreadingPerformanceMonitor.cs | +| ChunkParallelProcessor.cs | 252 | src/AdvChkSys\Threading\ChunkParallelProcessor.cs | +| ChunkManager3D.cs | 244 | src/AdvChkSys\Manager\ChunkManager3D.cs | +| ChunkThreadSafetyManager.cs | 237 | src/AdvChkSys\Threading\ChunkThreadSafetyManager.cs | +| ChunkThreadingExtensions2.cs | 223 | src/AdvChkSys\Threading\ChunkThreadingExtensions2.cs | +| Chunk3D.cs | 215 | src/AdvChkSys\Chunk\Chunk3D.cs | +| ChunkSerializer.cs | 194 | src/AdvChkSys\Serialization\ChunkSerializer.cs | +| Chunk2D.cs | 174 | src/AdvChkSys\Chunk\Chunk2D.cs | +| LimitedConcurrencyTaskScheduler.cs | 170 | src/AdvChkSys\Threading\LimitedConcurrencyTaskScheduler.cs | +| ChunkAsyncLock.cs | 167 | src/AdvChkSys\Threading\ChunkAsyncLock.cs | +| AdvChkSys.cs | 162 | src/AdvChkSys\AdvChkSys.cs | +| MemoryUsageReporter.cs | 140 | src/AdvChkSys\Diagnostics\MemoryUsageReporter.cs | +| LRUCache.cs | 135 | src/AdvChkSys\Util\LRUCache.cs | +| ChunkEvents.cs | 126 | src/AdvChkSys\Events\ChunkEvents.cs | +| MemoryHelper.cs | 101 | src/AdvChkSys\Util\MemoryHelper.cs | +| ChunkThreadingConfiguration.cs | 98 | src/AdvChkSys\Threading\ChunkThreadingConfiguration.cs | +| ChunkResourceManager.cs | 72 | src/AdvChkSys\Resources\ChunkResourceManager.cs | +| WorldConstraints.cs | 67 | src/AdvChkSys\Constraints\WorldConstraints.cs | +| ChunkTaskSchedulerExtensions.cs | 63 | src/AdvChkSys\Threading\ChunkTaskSchedulerExtensions.cs | +| ChunkExtensions.cs | 40 | src/AdvChkSys\Spatial\ChunkExtensions.cs | +| IChunkManager.cs | 38 | src/AdvChkSys\Interfaces\IChunkManager.cs | +| IChunk.cs | 36 | src/AdvChkSys\Interfaces\IChunk.cs | +| CacheCapacityHelper.cs | 30 | src/AdvChkSys\Util\CacheCapacityHelper.cs | +| AdvChkSys.AssemblyInfo.cs | 22 | src/AdvChkSys\obj\Debug\netstandard2.1\AdvChkSys.AssemblyInfo.cs | +| AdvChkSys.AssemblyInfo.cs | 22 | src/AdvChkSys\obj\Release\netstandard2.1\AdvChkSys.AssemblyInfo.cs | + ## Feature Status | Feature | Status | Description | Last Update | @@ -17,16 +62,15 @@ Last updated: 2025-05-11 | Thread Sync | [COMPLETED] | Explicit synchronization and concurrent collections | 2025-05-11 | | Spatial Interfaces | [COMPLETED] | Interface-level spatial query methods with support for custom filters | 2025-05-11 | | Parallel Processing | [COMPLETED] | Parallel processing of chunks based on spatial queries and regions | 2025-05-11 | +| Feature Tracking | [COMPLETED] | Track feature statuses | 2025-05-11 | | Priority Loading | [IN PROGRESS] | Prioritized chunk loading system (partially implemented) | 2025-05-10 | -| Dependency Tracking | [IN PROGRESS] | Dependency-aware disposal logic | 2025-05-10 | -| Dispose Pattern | [IN PROGRESS] | Full dispose pattern with finalizers for unmanaged resources | 2025-05-10 | +| Dependency Tracking | [IN PROGRESS] | Dependency-aware disposal logic (Partially Implemented) | 2025-05-10 | +| Dispose Pattern | [IN PROGRESS] | Full dispose pattern with finalizers for unmanaged resources (Partially Implemented) | 2025-05-10 | | Exception Handling | [IN PROGRESS] | Better async exception handling with specific types and logging | 2025-05-10 | | Performance Metrics | [IN PROGRESS] | Track load times, cache hit rates, and memory usage (partially implemented) | 2025-05-10 | -| Progress Tracking | [IN PROGRESS] | Track progress and auto-update status documents (mostly implemented) | 2025-05-10 | -| Git Integration | [IN PROGRESS] | Parse Git logs for status updates (partially implemented) | 2025-05-10 | -| Feature Tracking | [IN PROGRESS] | Track feature statuses (partially implemented) | 2025-05-10 | +| Progress Tracking | [IN PROGRESS] | Track progress and auto-update status documents (mostly implemented kinda still manual...) | 2025-05-11 | +| Git Integration | [IN PROGRESS] | Parse Git logs for status updates (partially implemented testing with this push.) | 2025-05-11 | | Doc Generation | [IN PROGRESS] | Auto-generate status docs and changelog (partially implemented) | 2025-05-10 | -| Todo Management | [IN PROGRESS] | Automate updates based on code reviews and commits | 2025-05-10 | | Dependency Interfaces | [PLANNED] | Interface-level dependency methods | 2025-05-10 | | Runtime Config | [PLANNED] | Runtime-adjustable configuration options | 2025-05-10 | | Known Issues | [IN PROGRESS] | Edge chunk unload delay under high concurrency | 2025-05-10 | diff --git a/scripts/track_progress.py b/scripts/track_progress.py index 4ef81a4..89cfdbe 100644 --- a/scripts/track_progress.py +++ b/scripts/track_progress.py @@ -20,10 +20,41 @@ CHANGELOG_TAG_RE = re.compile(r"\[changelog:(.+?)\]") FEATURE_TAG_RE = re.compile(r"\[feature:(\w+)\]") NEW_FEATURE_RE = re.compile(r"\[new-feature:(\w+):(.+?)\]") + # Ensure directories exist os.makedirs(os.path.dirname(STATUS_DOC), exist_ok=True) os.makedirs(os.path.dirname(FEATURES_FILE), exist_ok=True) + +def count_lines_of_code(): + """Count lines of code in the project and return statistics.""" + import os + import glob + + stats = {} + total_lines = 0 + file_stats = [] + + # Find all .cs files in the src/AdvChkSys directory and subdirectories + cs_files = glob.glob("src/AdvChkSys/**/*.cs", recursive=True) + + for file_path in cs_files: + with open(file_path, "r", encoding="utf-8", errors="ignore") as f: + lines = len(f.readlines()) + total_lines += lines + file_name = os.path.basename(file_path) + file_stats.append((file_name, lines, file_path)) + + # Sort by line count in descending order + file_stats.sort(key=lambda x: x[1], reverse=True) + + stats["total_lines"] = total_lines + stats["file_count"] = len(cs_files) + stats["files"] = file_stats + + return stats + + # Load features from Markdown file if it exists features = {} if os.path.exists(FEATURES_FILE): @@ -169,6 +200,21 @@ with open(STATUS_DOC, "w", encoding="utf-8") as f: f.write("# AdvChkSys Development Status\n\n") f.write(f"Last updated: {datetime.now().strftime('%Y-%m-%d')}\n\n") + # Add code statistics section + f.write("## Code Statistics\n\n") + code_stats = count_lines_of_code() + f.write(f"Total lines of code: **{code_stats['total_lines']}**\n\n") + f.write(f"Number of source files: **{code_stats['file_count']}**\n\n") + + f.write("### All Files by Line Count\n\n") + f.write("| File | Lines | Path |\n") + f.write("|------|------:|------|\n") + + for file_name, lines, file_path in code_stats["files"]: + f.write(f"| {file_name} | {lines} | {file_path} |\n") + + f.write("\n") + f.write("## Feature Status\n\n") f.write("| Feature | Status | Description | Last Update |\n") f.write("|---------|--------|-------------|-------------|\n") diff --git a/src/AdvChkSys/Threading/ChunkTaskSchedulerExtensions.cs b/src/AdvChkSys/Threading/ChunkTaskSchedulerExtensions.cs index e69de29..1156206 100644 --- a/src/AdvChkSys/Threading/ChunkTaskSchedulerExtensions.cs +++ b/src/AdvChkSys/Threading/ChunkTaskSchedulerExtensions.cs @@ -0,0 +1,63 @@ +#nullable enable +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace AdvChkSys.Threading +{ + /// + /// Provides additional methods for the ChunkTaskScheduler. + /// + public static class ChunkTaskSchedulerExtensions + { + /// + /// Maximum degree of parallelism for chunk operations. + /// + public static int MaxDegreeOfParallelism { get; set; } = Environment.ProcessorCount; + + /// + /// Runs a batch of actions in parallel. + /// + /// The actions to run + /// Maximum degree of parallelism (null for default) + /// Cancellation token + /// A task that completes when all actions are done + public static Task RunBatchParallelAsync( + Action[] actions, + int? maxDegreeOfParallelism = null, + CancellationToken cancellationToken = default) + { + if (actions == null || actions.Length == 0) + return Task.CompletedTask; + + return Task.Run(() => + { + var options = new ParallelOptions + { + MaxDegreeOfParallelism = maxDegreeOfParallelism ?? MaxDegreeOfParallelism, + CancellationToken = cancellationToken + }; + + Parallel.ForEach(actions, options, action => action()); + }, cancellationToken); + } + + /// + /// Creates a cancellation token with a timeout. + /// + /// The timeout + /// Optional token to combine with the timeout + /// A cancellation token that will be canceled after the timeout or when the input token is canceled + public static CancellationToken CreateTimeoutToken( + TimeSpan timeout, + CancellationToken cancellationToken = default) + { + if (timeout == TimeSpan.MaxValue) + return cancellationToken; + + var source = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + source.CancelAfter(timeout); + return source.Token; + } + } +} \ No newline at end of file