Fixed issues in the UI, added benchmark to compare with old juliaMSI library with the new custom one, incorporating platform detection and memory for amplifying cache pools
This commit is contained in:
+1
-1
@@ -129,7 +129,7 @@ end
|
||||
# --- Shared Constants ---
|
||||
const DEFAULT_CACHE_SIZE = 100
|
||||
const DEFAULT_NUM_BINS = 2000
|
||||
const DEFAULT_BLOOM_FILTER_SIZE = 1000 # Default size for empty spectra
|
||||
const DEFAULT_BLOOM_FILTER_SIZE = 10000 # Default size for empty spectra
|
||||
const DEFAULT_FALSE_POSITIVE_RATE = 0.01
|
||||
|
||||
"""
|
||||
|
||||
+36
-2
@@ -6,10 +6,44 @@ including caching and iteration logic, for handling large mzML and imzML dataset
|
||||
efficiently.
|
||||
"""
|
||||
|
||||
using Base64, Libz, Serialization, Printf, DataFrames, Base.Threads, StatsBase # For reading binary data
|
||||
using Base64, Libz, Serialization, Printf, DataFrames, Base.Threads, StatsBase
|
||||
using .Platform # Import the new Platform module
|
||||
|
||||
const FILE_HANDLE_LOCK = ReentrantLock()
|
||||
|
||||
"""
|
||||
calculate_optimal_analytics_chunk_size(total_spectra::Int, system_caps::NamedTuple) -> Int
|
||||
|
||||
Calculates an optimal chunk size for analytics processing based on total number of spectra
|
||||
and detected system capabilities (total memory, number of CPU threads).
|
||||
|
||||
The heuristic aims to balance memory usage and parallelism:
|
||||
- Smaller chunks for less memory or fewer threads.
|
||||
- Larger chunks for more memory or more threads, but with a practical upper limit.
|
||||
"""
|
||||
function calculate_optimal_analytics_chunk_size(total_spectra::Int, system_caps::NamedTuple)::Int
|
||||
# Base chunk size - can be refined with more profiling
|
||||
base_chunk_size = 5000
|
||||
|
||||
# Adjust based on available RAM (heuristic: more RAM, larger chunks)
|
||||
# Assume 1GB RAM can handle a certain chunk size comfortably
|
||||
# E.g., for 32GB RAM, allow 2x more than for 16GB
|
||||
memory_factor = max(1.0, system_caps.total_memory_gb / 16.0) # Scale based on 16GB baseline
|
||||
|
||||
# Adjust based on CPU threads (heuristic: more threads, potentially more, smaller chunks to keep threads busy, or fewer large chunks)
|
||||
# A simple approach for now: scale with sqrt of threads to avoid overly large chunks with many threads
|
||||
thread_factor = max(1.0, sqrt(system_caps.num_cpu_threads / 4.0)) # Scale based on 4-thread baseline
|
||||
|
||||
# Combine factors, with a practical minimum and maximum
|
||||
dynamic_chunk_size = round(Int, base_chunk_size * memory_factor * thread_factor)
|
||||
|
||||
# Ensure chunk size is within reasonable bounds
|
||||
min_chunk_size = 500
|
||||
max_chunk_size = 20000
|
||||
|
||||
return clamp(dynamic_chunk_size, min_chunk_size, max_chunk_size)
|
||||
end
|
||||
|
||||
"""
|
||||
ThreadSafeFileHandle
|
||||
|
||||
@@ -737,7 +771,7 @@ function precompute_analytics(msi_data::MSIData)
|
||||
bloom_filters = nothing
|
||||
|
||||
# Process in chunks to reduce memory pressure
|
||||
chunk_size = min(1000, num_spectra)
|
||||
chunk_size = min(10000, num_spectra)
|
||||
|
||||
for chunk_start in 1:chunk_size:num_spectra
|
||||
chunk_end = min(chunk_start + chunk_size - 1, num_spectra)
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# src/Platform.jl
|
||||
|
||||
module Platform
|
||||
|
||||
using Base.Threads # For Threads.nthreads()
|
||||
|
||||
# Export functions for system capability detection
|
||||
export detect_system_capabilities
|
||||
|
||||
"""
|
||||
detect_system_capabilities()
|
||||
|
||||
Detects and returns key system capabilities such as total memory and number of CPU threads.
|
||||
|
||||
# Returns
|
||||
- A `NamedTuple` with fields:
|
||||
- `total_memory_gb::Float64`: Total physical memory in gigabytes.
|
||||
- `num_cpu_threads::Int`: Number of available CPU threads.
|
||||
"""
|
||||
function detect_system_capabilities()::NamedTuple
|
||||
total_memory_bytes = Sys.total_memory()
|
||||
total_memory_gb = total_memory_bytes / (1024^3) # Convert bytes to gigabytes
|
||||
|
||||
num_cpu_threads = Sys.CPU_THREADS # Total logical CPU cores
|
||||
|
||||
return (total_memory_gb=total_memory_gb, num_cpu_threads=num_cpu_threads)
|
||||
end
|
||||
|
||||
end # module Platform
|
||||
Reference in New Issue
Block a user