: Introducing a new SimPy-inspired DES engine in Go (leveraging Go 1.23 Iterators)

27 views
Skip to first unread message

Roberto Roschel Belli

unread,
Mar 27, 2026, 6:48:44 PM (7 days ago) Mar 27
to python-simpy

Hi SimPy community and maintainers,

First, I want to thank you all for the incredible work on SimPy. Its process-based architecture has been the gold standard for discrete-event simulation, and its design philosophy heavily inspired a project I’ve been working on.

I am writing to share a new open-source Discrete Event Simulation (DES) engine written in Go, which attempts to faithfully replicate the SimPy experience while taking advantage of the latest advancements in the Go language.

In the past, developers trying to port SimPy to Go typically relied on standard goroutines and channels (chan) for process yielding. While functional, this approach often introduced heavy scheduling overhead and made the simulation kernel block on channel communication, hurting performance at scale.

To solve this, my implementation utilizes the new iter package (specifically iter.Pull) introduced in Go 1.23. By leveraging native coroutines for iteration, the engine achieves a true zero-block kernel.

Here are a few technical highlights of the engine:

  • True Coroutine Yielding: Simulation processes are written as sequential functions using yield(). They consume minimal stack memory and are suspended/resumed by the simulation environment without relying on the Go runtime scheduler.

  • Optimized Priority Queue: The event loop is powered by a custom container/heap implementation with internal index tracking, allowing for O(log n) performance even when reordering or canceling scheduled events.

  • Deterministic Ties: To ensure strict FIFO ordering when multiple processes request the same resource at the exact same virtual time, the engine uses an immutable indiceOrd counter.

  • Core Components: It currently implements Environment, Process, Resource, Store, Container, and Event triggers, mirroring SimPy's core capabilities.

You can check out the repository and the architectural details here: https://github.com/rbelligit/go_evt_simul

I would love to hear your feedback on this approach. If the team finds it valuable, I would be honored to have it considered for the "Ports" section in the official SimPy documentation.

Thank you again for the inspiration and for building such a robust simulation framework!

Best regards,

Roberto Roschel Belli

Peter Stahlecker

unread,
Mar 28, 2026, 3:59:01 PM (6 days ago) Mar 28
to python-simpy
Dear Roberto,

I used simpy some years ago - just for fun, I am retired.
It was absolutely amazing what it could do - and so easy to learn!

Just curiosity:
It seems to me simpy went dormant a few years ago.
Now you wake it up again, so to speak, but in a different language, go.
Why did you not stay with Python, likely the most popular computer language?

Thanks!

Peter

Roberto Roschel Belli

unread,
Mar 29, 2026, 4:55:02 PM (5 days ago) Mar 29
to python-simpy

Dear Peter,

I also used SimPy for simulations in the past and have always been a big fan of the library. Even back then, I often thought about implementing its core principles in a compiled language to achieve better performance.

I initially considered using C++ with the coroutines introduced in the newer standards, but I’ve been working with Go for a while now and really enjoy its ecosystem. When Go introduced the iter library, I saw a clear, high-performance path to bring the SimPy logic to Go. It's about keeping that great developer experience while gaining the speed of a compiled language.


Python is indeed an amazing and popular language, but many of its high-performance libraries are actually implemented in other languages for efficiency. By moving to Go, I can keep the simplicity of the code while benefiting from native, compiled performance right out of the box.


best regard,


Roberto Belli

Reply all
Reply to author
Forward
0 new messages