Skip to content

Fixes a cache-invalidation bug for SignalingList#3486

Merged
quaquel merged 3 commits intomesa:mainfrom
codebreaker32:resolve_fixme
Mar 9, 2026
Merged

Fixes a cache-invalidation bug for SignalingList#3486
quaquel merged 3 commits intomesa:mainfrom
codebreaker32:resolve_fixme

Conversation

@codebreaker32
Copy link
Copy Markdown
Collaborator

@codebreaker32 codebreaker32 commented Mar 9, 2026

Summary

Fixes a cache-invalidation bug for SignalingList. See #3481

Motivation

Because mutable lists mutate in-place, the reactive graph's current_val != old_val check compares the list's memory address against itself. It always evaluates to False, causing the @computed_property to return a stale cache. Furthermore, storing the actual list object in ComputedState traps massive data structures in memory.

Implementation

Passed None to the dependency tracker whenever the accessed value is a MutableSequence. This keeps the list out of the ComputedState and ensures in-place mutations successfully bypass the old != new cache check. Immutable standard observables remain unaffected.

Closes #3481

@codebreaker32 codebreaker32 changed the title Fixes a cache-invalidation bug for ObservableList Fixes a cache-invalidation bug for SignalingList Mar 9, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 9, 2026

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔴 +8.4% [+6.8%, +10.0%] 🔵 +0.0% [-0.1%, +0.2%]
BoltzmannWealth large 🔵 -1.6% [-2.1%, -0.9%] 🔵 -1.9% [-3.5%, -0.3%]
Schelling small 🔵 +0.6% [+0.3%, +1.0%] 🔵 +1.0% [+0.9%, +1.2%]
Schelling large 🔵 +1.2% [+0.6%, +1.7%] 🔵 +1.7% [+1.0%, +2.4%]
WolfSheep small 🔴 +3.8% [+3.0%, +4.5%] 🔵 +0.7% [+0.5%, +0.9%]
WolfSheep large 🟢 -5.1% [-6.7%, -3.4%] 🔵 -5.1% [-7.6%, -2.8%]
SugarscapeG1mt small 🔵 +0.5% [-0.4%, +1.3%] 🔵 +0.7% [+0.5%, +0.9%]
SugarscapeG1mt large 🔵 -0.3% [-1.2%, +0.7%] 🔵 +0.5% [+0.1%, +0.8%]
BoidFlockers small 🔵 -2.5% [-3.5%, -1.3%] 🔵 +1.9% [+1.6%, +2.1%]
BoidFlockers large 🔵 +0.6% [-0.6%, +1.6%] 🔵 +1.5% [+1.3%, +1.8%]

@quaquel quaquel added the bug Release notes label label Mar 9, 2026
@quaquel
Copy link
Copy Markdown
Member

quaquel commented Mar 9, 2026

Could you add a test that illustrates the bug as well? Otherwise, this looks good.

@codebreaker32
Copy link
Copy Markdown
Collaborator Author

Could you add a test that illustrates the bug as well? Otherwise, this looks good.

Good call, I was unintentionally returning that same None. Thanks :)

@quaquel quaquel merged commit d8f5f1c into mesa:main Mar 9, 2026
14 checks passed
@codebreaker32 codebreaker32 deleted the resolve_fixme branch March 9, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve a FIXME in mesa_signals/core.py

2 participants