Skip to content

feat!: add a reactive engine#5131

Open
S-furi wants to merge 29 commits intoAlchemistSimulator:masterfrom
S-furi:feat/reactive-engine
Open

feat!: add a reactive engine#5131
S-furi wants to merge 29 commits intoAlchemistSimulator:masterfrom
S-furi:feat/reactive-engine

Conversation

@S-furi
Copy link
Contributor

@S-furi S-furi commented Feb 13, 2026

No description provided.

@mergify
Copy link
Contributor

mergify bot commented Feb 13, 2026

Hi @S-furi! 👋
This pull request has conflicts 😖
Could you fix it? 🔧
Thank you! 🙏

@S-furi
Copy link
Contributor Author

S-furi commented Feb 13, 2026

@DanySK I have rebased master and resolved conflicts, now we have conflicts in this branch (I guess we will force push?). Do you need something else from my side?

@DanySK DanySK changed the base branch from feat/reactive-engine to master February 14, 2026 21:05
@DanySK DanySK changed the title chore(reactive-engine): rebase master and solve conflicts feat!: add a reactive engine (#5066) Feb 14, 2026
@DanySK
Copy link
Member

DanySK commented Feb 14, 2026

@S-furi I changed the base to master, I still see conflicts

@S-furi S-furi force-pushed the feat/reactive-engine branch 2 times, most recently from eb116fc to faad9c8 Compare February 15, 2026 17:11
@codecov
Copy link

codecov bot commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.53%. Comparing base (c7b7fab) to head (af2a3ac).

Additional details and impacted files
@@              Coverage Diff              @@
##             master    #5131       +/-   ##
=============================================
+ Coverage          0   61.53%   +61.53%     
- Complexity        0       14       +14     
=============================================
  Files             0        2        +2     
  Lines             0       78       +78     
  Branches          0        4        +4     
=============================================
+ Hits              0       48       +48     
- Misses            0       24       +24     
- Partials          0        6        +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}
useJUnitPlatform()
maxHeapSize = "1g"
"alchemist.engine".let { property ->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, it is a leftover to set the property to switch between classical and reactive engine. Removed in the next commit

@mergify
Copy link
Contributor

mergify bot commented Feb 15, 2026

Hi @S-furi! 👋
This pull request has conflicts 😖
Could you fix it? 🔧
Thank you! 🙏

@S-furi S-furi force-pushed the feat/reactive-engine branch from a29cc48 to 7ee9c71 Compare February 16, 2026 09:03
@DanySK DanySK changed the title feat!: add a reactive engine (#5066) feat!: add a reactive engine Feb 16, 2026
@DanySK DanySK requested review from cric96 and nicolasfara February 16, 2026 14:28
@DanySK
Copy link
Member

DanySK commented Feb 16, 2026

@nicolasfara @cric96

@S-furi created this reactive version of the alchemist engine. This radically changes how the simulator works. I'd propose a meeting where Stefano explains how it works, what is going to change, and then we replace the main Alchemist with this version.

Your feedback on the PR is also very appreciated.

@cric96
Copy link
Contributor

cric96 commented Feb 16, 2026

Wow! It seems promising, congrats :)
Anyway, let us try to organise a meeting and discuss this in detail!
Then, I will try to leave an in-depth review :)

@DanySK DanySK force-pushed the feat/reactive-engine branch 13 times, most recently from c5afdb5 to 4102b95 Compare February 21, 2026 13:01
S-furi and others added 29 commits March 6, 2026 00:18
# Conflicts:
#	.github/workflows/build-and-deploy.yml
#	.github/workflows/update-ancillary-files.yml
#	CHANGELOG.md
#	dokka-cache/ch.qos.logback/logback-classic/1.5.21.list
#	dokka-cache/ch.qos.logback/logback-classic/1.5.22.list
#	dokka-cache/ch.qos.logback/logback-classic/1.5.26.list
#	dokka-cache/de.flapdoodle.embed/de.flapdoodle.embed.mongo/4.21.0.list
#	dokka-cache/de.flapdoodle.embed/de.flapdoodle.embed.mongo/4.22.0.list
#	dokka-cache/de.flapdoodle.embed/de.flapdoodle.embed.mongo/4.24.0.list
#	dokka-cache/it.unibo.alchemist/alchemist-api/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-api/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-api/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-cognitive-agents/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-cognitive-agents/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-cognitive-agents/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-composeui/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-composeui/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-composeui/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-engine/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-engine/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-engine/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-euclidean-geometry/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-euclidean-geometry/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-euclidean-geometry/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-full/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-full/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-full/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-graphql-surrogates/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-graphql-surrogates/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-graphql-surrogates/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-graphql/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-graphql/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-graphql/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-implementationbase/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-implementationbase/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-implementationbase/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-biochemistry/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-biochemistry/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-biochemistry/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-protelis/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-protelis/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-protelis/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-sapere/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-sapere/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-incarnation-sapere/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-loading/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-loading/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-loading/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-maintenance-tooling/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-maintenance-tooling/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-maintenance-tooling/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-maps/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-maps/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-maps/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-physics/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-physics/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-physics/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-sapere-mathexp/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-sapere-mathexp/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-sapere-mathexp/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-smartcam/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-smartcam/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-smartcam/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-swingui/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-swingui/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-swingui/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-test/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-test/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-test/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-ui-tooling/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-ui-tooling/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-ui-tooling/42.3.32.list
#	dokka-cache/it.unibo.alchemist/alchemist-web-renderer/42.3.18.list
#	dokka-cache/it.unibo.alchemist/alchemist-web-renderer/42.3.22.list
#	dokka-cache/it.unibo.alchemist/alchemist-web-renderer/42.3.32.list
#	gradle/libs.versions.toml
#	package-lock.json
#	package.json
#	settings.gradle.kts

# Conflicts:
#	alchemist-engine/src/main/kotlin/it/unibo/alchemist/core/Engine.kt

# Conflicts:
#	alchemist-api/build.gradle.kts
#	alchemist-implementationbase/src/main/kotlin/it/unibo/alchemist/model/environments/AbstractEnvironment.kt
#	alchemist-loading/src/main/kotlin/it/unibo/alchemist/boundary/loader/LoadingSystem.kt
…l callback

Now the "laziness" concept is applied to dervied observables too.
For actions in general, it is better to use an imperative approach and retrieve the current neighborhood instead of having an up-to-date neighborhood version stored locally.
…ency graph

fix: remove obsolete reactive engine loading
chore(engine): use explicit synchronisation instead of thread contexts
This idea is borrowed by Androidx, where by means of Lifecycle state machines we are able to bound the lifecycle of the dependencies to the lifecycle of the owner (i.e. the registrant), properly disposing and releasing observers references withtout using weak references, hence not impacting too much negatively performance.
commit cbc430612a9a9063264da4f229fec1f7dc270ecd
Author: S-furi <stefano.furi7@gmail.com>
Date:   Fri Feb 20 14:02:00 2026 +0100

    perf(api): make use of persistent collections in observable collections

    this led to a great improvement in memory usage especially for neighbor-related streams where set of nodes where occupying large chunks of memory.

    This usage of persistent structures improved equality checks speed with an overall time reduction of approx a 10% wrt standard kotlin collections usage (from 22s independent test (SAPERE) to 20s)

commit ef9301aed3555d7d97c262a755085ace39bc9c24
Author: S-furi <stefano.furi7@gmail.com>
Date:   Fri Feb 20 11:53:17 2026 +0100

    perf(engine): introduce `BatchManager` to avoid redundant reschedule requests

commit 6c04f40fcea4ce9f644cf2b9e162b999199d524e
Author: S-furi <stefano.furi7@gmail.com>
Date:   Fri Feb 20 11:18:14 2026 +0100

    perf(sapere): introduce finer-grained observables for lsa spaces
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants