Commit Graph

6 Commits

Author SHA1 Message Date
Huamonarch
02447c733a Replace U+00B5 (MICRO SIGN) with plain 'us' to avoid Unicode warning
Gitea flags U+00B5 as ambiguous — visually identical to U+03BC
(GREEK SMALL LETTER MU). Using 'us' is the standard engineering
abbreviation and avoids the warning.
2026-05-13 10:33:08 +08:00
Huamonarch
9bb810d9ed Replace broken ColdMutex with dual-layer ShmSpinLock + std::mutex
The old ColdMutex (interprocess_mutex) was in process-local anonymous
namespace storage, so each process had its own copy — no actual
cross-process exclusion. Even if moved to SHM, interprocess_mutex is
not robust: a crash while holding the lock would deadlock on restart.

New design:
- ShmSpinLock: atomic<pid_t> in shared memory, kill(pid,0) detects
  dead owners (ESRCH → takeover), crash-safe by construction
- std::mutex: process-local, handles intra-process thread contention
  without burning CPU on the SHM spinlock
- DualLock: locks local first, then shm; unlocks in reverse

9 lock sites in MapRuleStat upgraded to std::lock_guard<DualLock>.
2026-05-13 10:21:55 +08:00
Huamonarch
df79a9a1a5 Fix: add default constructor to TaskRecord for map operator[]
boost::container::map::operator[] default-constructs the mapped_type
when the key doesn't exist. TaskRecord lacked a default constructor
after the e21b2af refactor (only had an allocator-arg constructor).
Added a static vec_allocator_f (matching RuleStatShm.h pattern) and a
default constructor that initializes data_record with it.
2026-05-13 09:27:29 +08:00
Huamonarch
e21b2af2a6 Replace fixed 518MB array in TaskData with dynamic shared-memory vector
DataRecord used a fixed float[129600000] consuming 5GB disk even when
collecting only a few hundred data points. Replaced with shm_vector_f
that grows on demand via push_back. Removes the need for rm -rf on
process exit — vector destructor frees memory back to the segment.
Also drops now-unnecessary task_data_size member.
2026-05-12 17:19:44 +08:00
Huamonarch
973921fc4b Split RuleStat display from cold data paths to reduce lock contention
Display data (alarm_value, current_value, limit_up/down, items, unit) now
goes to a local-memory DisplayCache and is serialized to JSON without any
shared memory lock. Cold data (stat_values, running_time, shear_times, etc.)
stays in shared memory for mon-cron IPC, protected by a real interprocess
mutex (boost::interprocess::interprocess_mutex) instead of the broken
process-local std::mutex. AlgBase::rule_stat_ is now RuleStatLocal with
standard types — zero changes to algorithm subclass code.
2026-05-12 15:46:01 +08:00
Huamonarch
7e602c7bc1 Initial commit: EIS C++ project with multi-process code 2026-05-09 11:23:45 +08:00