event-sourcing icon indicating copy to clipboard operation
event-sourcing copied to clipboard

Add event to split the stream

Open DanielBadura opened this issue 3 years ago • 1 comments

PoC of archiving events based on a marker attribute. If an event with this marker attribute is going to be saved, then all past events get archived. Then only the non archived events get loaded to rebuild the aggregate. That means that those marked events need to hold all data needed to re-create the aggregate to the same state as it is in the moment. If this is not given the whole system is going to break.

Why are we doing this? There is for one a performance boost if we are having really big stream for aggregates it could take some time to recreate them if we are going through millions of events. With this we can like start again from one event. Some businesses also require some kind of monthly or yearly reset of the stream.

DanielBadura avatar Jul 30 '22 11:07 DanielBadura

Hello :wave:

here is the most recent benchmark result:

WriteEventsBench
================

Average iteration times by variant

47.1ms    │    █  
41.2ms    │    █▄ 
35.3ms    │    ██ 
29.4ms    │    ██ 
23.6ms    │    ██ 
17.7ms    │    ██ 
11.8ms    │    ██ 
5.9ms     │ ▂▂ ██ 
          └───────
            1  2  

[█ <current>] [█ base] 

1: benchSaveOneEvent    2: benchSaveAfterThous᠁ 

Memory by variant

7.4mb     │ ▂▂ ██ 
6.5mb     │ ██ ██ 
5.5mb     │ ██ ██ 
4.6mb     │ ██ ██ 
3.7mb     │ ██ ██ 
2.8mb     │ ██ ██ 
1.8mb     │ ██ ██ 
924.5kb   │ ██ ██ 
          └───────
            1  2  

[█ <current>] [█ base] 

1: benchSaveOneEvent    2: benchSaveAfterThous᠁ 

+---------------------------------+-------------------+-------------------+-----------------+------------+
|                                 | time (kde mode)                       | memory                       |
+---------------------------------+-------------------+-------------------+-----------------+------------+
| subject                         | Tag: <current>    | Tag: base         | Tag: <current>  | Tag: base  |
+---------------------------------+-------------------+-------------------+-----------------+------------+
| benchSaveOneEvent ()            | 1.049ms (±1.82%)  | 1.172ms (±1.98%)  | 6.672mb         | 6.653mb    |
| benchSaveAfterThousandEvents () | 47.109ms (±1.13%) | 38.227ms (±0.70%) | 7.396mb         | 7.348mb    |
+---------------------------------+-------------------+-------------------+-----------------+------------+

LoadEventsWithSnapshotsBench
============================

Average iteration times by variant

280.2μs   │ █▅ 
245.1μs   │ ██ 
210.1μs   │ ██ 
175.1μs   │ ██ 
140.1μs   │ ██ 
105.1μs   │ ██ 
70.0μs    │ ██ 
35.0μs    │ ██ 
          └────
            1  

[█ <current>] [█ base] 

1: benchLoadEvents 

Memory by variant

14.6mb    │ █▇ 
12.8mb    │ ██ 
10.9mb    │ ██ 
9.1mb     │ ██ 
7.3mb     │ ██ 
5.5mb     │ ██ 
3.6mb     │ ██ 
1.8mb     │ ██ 
          └────
            1  

[█ <current>] [█ base] 

1: benchLoadEvents 

+--------------------+--------------------+--------------------+-----------------+------------+
|                    | time (kde mode)                         | memory                       |
+--------------------+--------------------+--------------------+-----------------+------------+
| subject            | Tag: <current>     | Tag: base          | Tag: <current>  | Tag: base  |
+--------------------+--------------------+--------------------+-----------------+------------+
| benchLoadEvents () | 280.150μs (±0.09%) | 263.047μs (±0.63%) | 14.590mb        | 14.245mb   |
+--------------------+--------------------+--------------------+-----------------+------------+

LoadEventsBench
===============

Average iteration times by variant

103.6ms   │ █▇ 
90.7ms    │ ██ 
77.7ms    │ ██ 
64.8ms    │ ██ 
51.8ms    │ ██ 
38.9ms    │ ██ 
25.9ms    │ ██ 
13.0ms    │ ██ 
          └────
            1  

[█ <current>] [█ base] 

1: benchLoadEvents 

Memory by variant

24.2mb    │ █  
21.2mb    │ █▇ 
18.1mb    │ ██ 
15.1mb    │ ██ 
12.1mb    │ ██ 
9.1mb     │ ██ 
6.0mb     │ ██ 
3.0mb     │ ██ 
          └────
            1  

[█ <current>] [█ base] 

1: benchLoadEvents 

+--------------------+--------------------+--------------------+-----------------+------------+
|                    | time (kde mode)                         | memory                       |
+--------------------+--------------------+--------------------+-----------------+------------+
| subject            | Tag: <current>     | Tag: base          | Tag: <current>  | Tag: base  |
+--------------------+--------------------+--------------------+-----------------+------------+
| benchLoadEvents () | 103.601ms (±0.11%) | 101.313ms (±0.40%) | 24.193mb        | 20.649mb   |
+--------------------+--------------------+--------------------+-----------------+------------+

This comment gets update everytime a new commit comes in!

github-actions[bot] avatar Aug 07 '22 11:08 github-actions[bot]