@the-w1zard/singularity 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.html +450 -0
  2. package/README.md +327 -2
  3. package/dist/bus_db_rpc/RULE_OF_2_same_node.d.ts +139 -0
  4. package/dist/bus_db_rpc/RULE_OF_2_same_node.d.ts.map +1 -0
  5. package/dist/bus_db_rpc/RULE_OF_2_same_node.js +502 -0
  6. package/dist/class.d.ts +161 -0
  7. package/dist/class.d.ts.map +1 -0
  8. package/dist/class.js +804 -0
  9. package/dist/comps/DISRUPTOR_CRYPTO.d.ts +47 -0
  10. package/dist/comps/DISRUPTOR_CRYPTO.d.ts.map +1 -0
  11. package/dist/comps/RULE_OF_2_same_app.d.ts +175 -0
  12. package/dist/comps/RULE_OF_2_same_app.d.ts.map +1 -0
  13. package/dist/comps/RULE_OF_2_same_app.js +482 -0
  14. package/dist/comps/binary.d.ts +71 -0
  15. package/dist/comps/binary.d.ts.map +1 -0
  16. package/dist/comps/byte_id.d.ts +12 -0
  17. package/dist/comps/byte_id.d.ts.map +1 -0
  18. package/dist/comps/cell-worker.d.ts +9 -0
  19. package/dist/comps/cell-worker.d.ts.map +1 -0
  20. package/dist/comps/cell.d.ts +349 -0
  21. package/dist/comps/cell.d.ts.map +1 -0
  22. package/dist/comps/create_live_self.d.ts +22 -0
  23. package/dist/comps/create_live_self.d.ts.map +1 -0
  24. package/dist/comps/queue.d.ts +103 -0
  25. package/dist/comps/queue.d.ts.map +1 -0
  26. package/dist/comps/serializer.d.ts +30 -0
  27. package/dist/comps/serializer.d.ts.map +1 -0
  28. package/dist/comps/serializer.js +131 -0
  29. package/dist/comps/vm-types.d.ts +20 -0
  30. package/dist/comps/vm-types.d.ts.map +1 -0
  31. package/dist/db/binary.d.ts +76 -0
  32. package/dist/db/binary.d.ts.map +1 -0
  33. package/dist/db/binary.js +441 -0
  34. package/dist/db/client.d.ts +28 -0
  35. package/dist/db/client.d.ts.map +1 -0
  36. package/dist/db/client.js +82 -0
  37. package/dist/db/db.d.ts +141 -0
  38. package/dist/db/db.d.ts.map +1 -0
  39. package/dist/db/db.js +898 -0
  40. package/dist/db/op.d.ts +13 -0
  41. package/dist/db/op.d.ts.map +1 -0
  42. package/dist/db/op.js +11 -0
  43. package/dist/db/storage-worker.d.ts +2 -0
  44. package/dist/db/storage-worker.d.ts.map +1 -0
  45. package/dist/db/storage-worker.js +152 -0
  46. package/dist/db/types.d.ts +134 -0
  47. package/dist/db/types.d.ts.map +1 -0
  48. package/dist/db/types.js +14 -0
  49. package/dist/db/wal.d.ts +30 -0
  50. package/dist/db/wal.d.ts.map +1 -0
  51. package/dist/db/wal.js +217 -0
  52. package/dist/index.d.ts +2 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/signals.js +10740 -5498
  55. package/dist/slab.d.ts +95 -0
  56. package/dist/slab.d.ts.map +1 -0
  57. package/dist/slab.js +575 -0
  58. package/dist/slab.types.d.ts +5 -0
  59. package/dist/slab.types.d.ts.map +1 -0
  60. package/dist/slab.types.js +1 -0
  61. package/dist/test.d.ts +152 -0
  62. package/dist/test.d.ts.map +1 -0
  63. package/dist/test.js +1183 -0
  64. package/dist/testt.d.ts +61 -0
  65. package/dist/testt.d.ts.map +1 -0
  66. package/dist/testt.js +143 -0
  67. package/dist/y.d.ts +152 -0
  68. package/dist/y.d.ts.map +1 -0
  69. package/dist/y.js +36 -65
  70. package/package.json +22 -19
package/README.md CHANGED
@@ -41,8 +41,7 @@
41
41
  </div>
42
42
  <br clear="right">
43
43
 
44
-
45
-
44
+
46
45
  > [!NOTE]
47
46
  >
48
47
  > The entire goal of the dark side, power and performance. Nothing else matters...
@@ -3323,8 +3322,149 @@ Average: 11.36 M ops/sec
3323
3322
  ---------------------------------------------------------
3324
3323
  ```
3325
3324
 
3325
+ After performance update
3326
+ ```txt
3327
+ ------------ RAVEN.store.get ---------------
3328
+ Peak (Best Batch): 259.34 M ops/sec
3329
+ Average: 105.75 M ops/sec
3330
+ ---------------------------------------------------------
3331
+ ------------ RAVEN.store.has ---------------
3332
+ Peak (Best Batch): 251.70 M ops/sec
3333
+ Average: 25.86 M ops/sec
3334
+ ---------------------------------------------------------
3335
+ ------------ RAVEN.store.set ---------------
3336
+ Peak (Best Batch): 64.93 M ops/sec
3337
+ Average: 33.37 M ops/sec
3338
+ ---------------------------------------------------------
3339
+ ------------ RAVEN.store.set.functional ---------------
3340
+ Peak (Best Batch): 39.16 M ops/sec
3341
+ Average: 26.11 M ops/sec
3342
+ ---------------------------------------------------------
3343
+ ------------ RAVEN.store.get.set ---------------
3344
+ Peak (Best Batch): 54.02 M ops/sec
3345
+ Average: 48.20 M ops/sec
3346
+ ---------------------------------------------------------
3347
+ ------------ RAVEN.store.entries ---------------
3348
+ Peak (Best Batch): 7.51 M ops/sec
3349
+ Average: 6.62 M ops/sec
3350
+ ---------------------------------------------------------
3351
+ ------------ RAVEN.store.subscribe ---------------
3352
+ Peak (Best Batch): 2.55 M ops/sec
3353
+ Average: 2.32 M ops/sec
3354
+ ---------------------------------------------------------
3355
+ ------------ RAVEN.store.persist.get ---------------
3356
+ Peak (Best Batch): 59.26 M ops/sec
3357
+ Average: 48.68 M ops/sec
3358
+ ---------------------------------------------------------
3359
+ ------------ RAVEN.store.persist.has ---------------
3360
+ Peak (Best Batch): 72.35 M ops/sec
3361
+ Average: 64.40 M ops/sec
3362
+ ---------------------------------------------------------
3363
+ ------------ RAVEN.store.persist.set ---------------
3364
+ Peak (Best Batch): 50.32 M ops/sec
3365
+ Average: 47.28 M ops/sec
3366
+ ---------------------------------------------------------
3367
+ ------------ RAVEN.state.get ---------------
3368
+ Peak (Best Batch): 53.19 M ops/sec
3369
+ Average: 33.23 M ops/sec
3370
+ ---------------------------------------------------------
3371
+ ------------ RAVEN.state.getHot ---------------
3372
+ Peak (Best Batch): 145.39 M ops/sec
3373
+ Average: 107.64 M ops/sec
3374
+ ---------------------------------------------------------
3375
+ ------------ RAVEN.state.set ---------------
3376
+ Peak (Best Batch): 33.32 M ops/sec
3377
+ Average: 18.04 M ops/sec
3378
+ ---------------------------------------------------------
3379
+ ------------ RAVEN.state.get.set ---------------
3380
+ Peak (Best Batch): 80.10 M ops/sec
3381
+ Average: 61.39 M ops/sec
3382
+ ---------------------------------------------------------
3383
+ ------------ RAVEN.state.getAll ---------------
3384
+ Peak (Best Batch): 6.68 M ops/sec
3385
+ Average: 5.65 M ops/sec
3386
+ ---------------------------------------------------------
3387
+ ------------ RAVEN.state.getByPrefix ---------------
3388
+ Peak (Best Batch): 4.68 M ops/sec
3389
+ Average: 4.17 M ops/sec
3390
+ ---------------------------------------------------------
3391
+ ------------ RAVEN.state.subscribe ---------------
3392
+ Peak (Best Batch): 2.90 M ops/sec
3393
+ Average: 2.64 M ops/sec
3394
+ ---------------------------------------------------------
3395
+ ------------ RAVEN.state.notify ---------------
3396
+ Peak (Best Batch): 1.18 M ops/sec
3397
+ Average: 0.96 M ops/sec
3398
+ ---------------------------------------------------------
3399
+ ------------ RAVEN.darkState.get ---------------
3400
+ Peak (Best Batch): 2.57 M ops/sec
3401
+ Average: 2.08 M ops/sec
3402
+ ---------------------------------------------------------
3403
+ ------------ RAVEN.darkState.set ---------------
3404
+ Peak (Best Batch): 15.56 M ops/sec
3405
+ Average: 14.42 M ops/sec
3406
+ ---------------------------------------------------------
3407
+ ------------ RAVEN.darkState.get.set ---------------
3408
+ Peak (Best Batch): 2.19 M ops/sec
3409
+ Average: 1.80 M ops/sec
3410
+ ---------------------------------------------------------
3411
+ ------------ RAVEN.darkState.selector.get ---------------
3412
+ Peak (Best Batch): 2.46 M ops/sec
3413
+ Average: 1.77 M ops/sec
3414
+ ---------------------------------------------------------
3415
+ ------------ RAVEN.darkState.selector.set ---------------
3416
+ Peak (Best Batch): 8.58 M ops/sec
3417
+ Average: 8.18 M ops/sec
3418
+ ---------------------------------------------------------
3419
+ ------------ RAVEN.darkState.derived.get ---------------
3420
+ Peak (Best Batch): 2.47 M ops/sec
3421
+ Average: 1.91 M ops/sec
3422
+ ---------------------------------------------------------
3423
+ ------------ RAVEN.darkState.derived.set ---------------
3424
+ Peak (Best Batch): 12.58 M ops/sec
3425
+ Average: 12.15 M ops/sec
3426
+ ---------------------------------------------------------
3427
+ ```
3428
+
3326
3429
  </details>
3327
3430
 
3431
+ > [!NOTE] BUILDERS LOG #16
3432
+ >
3433
+ > TLDR: design bench so that the test runs in the sub one sec time window or when 11 secs has elapsed. This rule would remove all variables concerning v8.
3434
+ >
3435
+ > The discrepency in numbers... man, am I fucking so happy that... it dawned on me when it did hahaha, or else I would literally be here for days trying to figure this out...
3436
+ >
3437
+ > SOOOOO... couple of things are working against us, thankfully I only wasted like 20 mins on this, but since we are now benching against the real live implementation in place of a set up bench and harness it changes how we hit v8 than we did previously.
3438
+ >
3439
+ > The implementation has a ready boolean to signify once everything has been initalised, that is part of the problem.
3440
+ >
3441
+ > The second problem was where exactly during v8s execution window, were we hitting exactly. For those of you that dont know v8s execution window starts with the largest burst of performance fitting within a sub 1 second window. Which is how 99% of all users us v8, which is why this exists. If v8 continues to run, it sees a massive dip, obviously, following the burst up till around the 5-6 second mark. When it expereiences another dip, due to handing off the process to v8s turbo. From here... it takes till the around the 10 sec mark to finally start hitting v8s turbo when it has fully initialized.
3442
+ >
3443
+ > Basically... the hot paths we were testing fucking... just hit it at all the wrong times as you can see here:
3444
+ > ```txt
3445
+ > ------------ RAVEN.state.getHot2 ---------------
3446
+ > Peak (Best Batch): 1453.49 M ops/sec
3447
+ > Average: 587.23 M ops/sec
3448
+ > ---------------------------------------------------------
3449
+ > ------------ RAVEN.state.getHot ---------------
3450
+ > Peak (Best Batch): 376.36 M ops/sec
3451
+ > Average: 206.64 M ops/sec
3452
+ > ---------------------------------------------------------
3453
+ > ```
3454
+ > Prior to this run, both hot paths were only hitting 100 mill lol... as you can see here, hot 2 is hitting the burst on its way down since it is only getting 1453 here, when it should be getting almost 1700. getHot, previousl runs at 100, now almost at the very end of the burst is at 375... sooo...
3455
+ >
3456
+ > In order to have complete control and give each test the same variables... we need to design the tests differently, that way each test atleast has the same parameters to run that way we aren't accidently changing them from test to test and not making us wonder about life on why one test is so much slower then the next. When in reality, it literally has nothing to do with the code, the bench or the harness... but in fact, it was v8 all along.
3457
+ >
3458
+ > But let me be clear. We are NOT designing your average bench mark of warm up phase, fucking 5+ seconds of other bullshit and then finally start testing for another 10 secs or whatever stupid and dumb processs they designed. THAT IS NOT HOW THE REAL WORLD USES V8, but instead benchmarkers, for whatever reason, bench against a made up and unreal synthetic test. The numbers do not translate to the real world in any form, but maybe sub 1% of use cases.
3459
+ >
3460
+ > There is a reason why v8 sub 1 sec performance... bursts the way it does. Since users only hit either the sub 1 burst, or when turbo has already flattened.
3461
+ >
3462
+ > The next time you create a test, keep that in mind. Because you may not even be hitting v8 at the exact timing you should be.
3463
+ >
3464
+ > If you do not beleive a fucking word of this... that's ok, go to the message queues repo... download the main test, and run vader, rule of 2, and raven and these three disruptors will give you an exact look into how v8s execution process actually runs in real time. And you can hit it as many times as you want to witness it.
3465
+ >
3466
+ > I would suggest keeping the tests to sub 20secs because at the 26 sec mark, you will heat soak the core and performance will drop based on your thermal situation. To run these tests, there is literally 0 configuration, just run 'bun run test.ts' since buns performance is much higher than nodes, and run the non-bare metal test. As the bare metal test does not log the results per second, but instead once when the test ends.
3467
+ >
3328
3468
 
3329
3469
  <details style="font-size: 14.5px;"><summary><strong><span style="font-size: 16px; font-family: monospace">[THE DARK SIDE: USE STATE]</span> </strong></summary>
3330
3470
 
@@ -3438,3 +3578,188 @@ Average: 11.36 M ops/sec
3438
3578
 
3439
3579
  </details>
3440
3580
 
3581
+ > [!NOTE] BUILDERS LOG #16
3582
+ >
3583
+ > I'm adding some final touches on the message queue and its adapters and an idea just came to me... along with a question... why do we always just create... a signle sub... when in reality there are in fact 2 subs, there is the one that devs usualy and almost 100% use which is the sub and unsub version, where you create the sub at the call site but also immediatly unsub the sub as soon as the first message comes in....
3584
+ >
3585
+ > Then theres the second kind, the kind that you do not want to unsub, the long standing version and in fact want it to stay open...
3586
+ >
3587
+ > It is super late in the game to change the api, but this would be adding to it in a way that won't disrupt the current paths, where they will stay the way they are as it already exposes the unsub version, and we simply just add the new one beside it.
3588
+ >
3589
+ ```tsx
3590
+ public sub = (() => {
3591
+ const fn = (handler: A, k: S, s: S = '_globalThis', m: S = this.m, r: S = this.r, c: c_type = "globalThis" ): () => V => {
3592
+ let unsub: () => V = () => {};
3593
+ const once_handler: A = (p: U) => {unsub();handler(p);};
3594
+ unsub = this.sub_infinity(once_handler, k, s, m, r, c);
3595
+ return unsub;
3596
+ };
3597
+
3598
+ public sub_infinity = (() => {
3599
+ const fn = (handler: A, k: S, s: S = '_globalThis', m: S = this.m, r: S = this.r, c: c_type = "globalThis"): () => V => {
3600
+ // CHANNEL LEVEL
3601
+ const channelSet = (mesh.getR(r, c)[r] ??= new Set<A>()) as Set<A>;
3602
+ channelSet.add(handler);
3603
+
3604
+ // SUB_CHANNEL LEVEL
3605
+ const subMap = mesh.getM(m, r, c);
3606
+ const subSet = (subMap[r] ??= new Set<A>()) as Set<A>;
3607
+ subSet.add(handler);
3608
+
3609
+ // TRIP_CHANNEL LEVEL
3610
+ const tripMap = mesh.getS(s, m, r, c);
3611
+ const tripSet = (tripMap[m] ??= new Set<A>()) as Set<A>;
3612
+ tripSet.add(handler);
3613
+
3614
+ // QUAD_CHANNEL LEVEL
3615
+ const quadMap = (tripMap[k] ??= Object.create(null)) as Record<S, Set<A>>;
3616
+ const quadSet = (quadMap[s] ??= new Set<A>()) as Set<A>;
3617
+ quadSet.add(handler);
3618
+
3619
+ return () => {
3620
+ // QUAD_CHANNEL
3621
+ quadSet.delete(handler);
3622
+ if (!quadSet.size) delete quadMap[s];
3623
+ if (!Object.keys(quadMap).length) delete tripMap[k];
3624
+
3625
+ // TRIP_CHANNEL
3626
+ tripSet.delete(handler);
3627
+ if (!tripSet.size) delete tripMap[m];
3628
+
3629
+ // SUB_CHANNEL
3630
+ subSet.delete(handler);
3631
+ if (!subSet.size) delete subMap[r];
3632
+
3633
+ // CHANNEL
3634
+ channelSet.delete(handler);
3635
+ if (!channelSet.size) delete mesh.getR(r, c)[r];
3636
+
3637
+ // Remove empty hierarchy nodes
3638
+ if (!Object.keys(subMap).length) { delete mesh.getR(c, r)[m]; }
3639
+ if (!Object.keys(tripMap).length) { delete mesh.getR(c, r)[m]; }
3640
+ };
3641
+ };
3642
+
3643
+ return fn;
3644
+ })();
3645
+ ```
3646
+
3647
+ > [!NOTE] BUILDERS LOG #17
3648
+ >
3649
+ > With moving everything over onto the main platform now that the dark side is done... I thought, I'll spend an hour on the new signals implementation... currently alien is only winning in 8 tests, so I might jsut finish this out. Some areas its beating alien by... not so much but in others it is doing it by a 2-5x, not bad. But it is taking a while, since I have no idea what it is that I'm doing so its basically, make change... bench, make change, bench... lol.
3650
+ >
3651
+ > So an update, kept widdling it down where alien only wins in 4 tests now... Honestly, what I think I'll do now as far as the platform goes, is move the current signals solution over to the light side, and have my implemenation on the dark side.
3652
+ >
3653
+ > This actually does meet the criteria of both, but I'm more than sure with some more time I can get the rest of the tests beaten as well. Because I beleive I've only worked on this for about 4-5 hours so far, so with time I'm hoping to beat the remaining tests... who knows.
3654
+ >
3655
+ > [update] now this is the first time an ai produced this state and its interesting:
3656
+ > - alien mean peak, 105.01 mill
3657
+ > - signals mean peak, 197,74 mill
3658
+ >
3659
+ > - alien mean average, 63.04 mill
3660
+ > - signals mean average, 97.68 mill
3661
+ >
3662
+ > and this is despite alien dominating in 2 out or the 3 categories it wins in, which I need to figure that category out... but still, it beats signals by liek a 2x as well which means signals has enough through put through out the other tests to produce that stat... Thought that was intersting.
3663
+ >
3664
+ > [update] I was able to widdle away the majority of the wins alien had, if I remember correctly in the one it was really winning at was a 2.1x to now being a 13% peak and 6% avg win for alien. The following numbers are 4 runs for alien and 4 runs for the new solution, averages each others scores seperatly then calculating the percentage based on each others averages so as to not have the test fluctuate to one side or the other due to harness / bench noise. So this gives the best look at it, on my machine anyways. The conducted tests are literally... line by line the exact same on the bench. The bench is available for you to run it yourself, if you don't like the numbers than your more than welcome to calculate the hundreds of values that the bench will output yourself so you can see that the results are genuine. As I won't be surprised if this pisses of a couple of people, which is why everything is available for you to run at home, or on a massively expensive node at work.
3665
+ >
3666
+ > Tbh, I truly didn't think anything would come out of this, and I don't care whether its my solution that wins or not... because up till the decision I just made, alien was the only solution that was going to be available in the platform. Because why would I bother with something slower. Instead of getting rid of alien altogether, I'm moving it over to the light side and throwing my implementation into the dark side. For me, I'm truly switzerland in these tests and I just want the actual best solution. So rip apart the bench all you want, it won't hurt my feelings, LOL. Next year, there will be a new alien out there somewhere that will come out. Just like the toddler song, 'this is the game that never ends...', lol
3667
+
3668
+ ```tsx
3669
+ SIGNAL_ENGINE.signal.get
3670
+ 8.85948894360474
3671
+ 14.2209512048486
3672
+ SIGNAL_ENGINE.signal.peek
3673
+ 240.540619067911
3674
+ 259.435320672478
3675
+ SIGNAL_ENGINE.signal.set
3676
+ 20.5109878387028
3677
+ 39.4535923259304
3678
+ SIGNAL_ENGINE.signal.get.set
3679
+ 236.13180659033
3680
+ 177.617370892019
3681
+ SIGNAL_ENGINE.computed.get.cached
3682
+ 101.736123119488
3683
+ 96.651639502177
3684
+ SIGNAL_ENGINE.computed.invalidate
3685
+ -1.12156931738214
3686
+ 7.36293495478004
3687
+ SIGNAL_ENGINE.computed.recompute
3688
+ 39.5842885526517
3689
+ 58.0365381066618
3690
+ SIGNAL_ENGINE.computed.chain.cached
3691
+ -13.8114948209468
3692
+ -6.60815047021943
3693
+ SIGNAL_ENGINE.computed.chain.recompute
3694
+ -8.75745071068318
3695
+ 2.30439442658093
3696
+ SIGNAL_ENGINE.effect.create-dispose
3697
+ 15.8163917657588
3698
+ 10.7221006564552
3699
+ SIGNAL_ENGINE.effect.notify
3700
+ 73.959673959674
3701
+ 98.8611713665944
3702
+ SIGNAL_ENGINE.effect.cleanup-rerun
3703
+ 66.9087464477424
3704
+ 62.0821727019499
3705
+ SIGNAL_ENGINE.dependency.track
3706
+ 55.0591327201052
3707
+ 72.3458359821996
3708
+ SIGNAL_ENGINE.fanout.16
3709
+ 45.7875457875458
3710
+ 116.901408450704
3711
+ SIGNAL_ENGINE.fanout.64
3712
+ 14.7239263803681
3713
+ 17.9487179487179
3714
+ SIGNAL_ENGINE.batch.3-writes
3715
+ 53.3158637371498
3716
+ 41.2512658940025
3717
+ SIGNAL_ENGINE.batch.effect.3-writes
3718
+ 91.2375096079938
3719
+ 76.701030927835
3720
+ SIGNAL_ENGINE.graph.diamond.cached
3721
+ 44.7262784338821
3722
+ 37.2290784060908
3723
+ SIGNAL_ENGINE.graph.diamond.recompute
3724
+ 2.8140013726836
3725
+ 4.38917337234821
3726
+ SIGNAL_ENGINE.graph.branch.16.cached
3727
+ 34.3943755535872
3728
+ 37.3974800903364
3729
+ SIGNAL_ENGINE.graph.branch.16.recompute
3730
+ 13.7777777777778
3731
+ 14.6788990825688
3732
+ ```
3733
+ > [!NOTE]
3734
+ >
3735
+ > Then for the average of peaks and averages
3736
+ >
3737
+ > | Engine | Average peak (M ops/sec) | Average average (M ops/sec) |
3738
+ > |---|---:|---:|
3739
+ > | Alien | 135.38 | 67.24 |
3740
+ > | Signals | 202.09 | 109.08 |
3741
+ > The following numbers are 4 runs for alien and 4 runs for the new solution, averages each others scores seperatly then calculating the percentage based on each others averages so as to not have the test fluctuate to one side or the other due to harness / bench noise. So this gives the best look at it, on my machine anyways. The conducted tests are literally... line by line the exact same on the bench. The bench is available for you to run it yourself
3742
+
3743
+ > [!NOTE] BUILDERS LOG #18
3744
+ >
3745
+ > Ah fuck... I don't think I can make the new db into an adapter that would just fit into the main db... thats fucking balls... mother fucker...
3746
+ >
3747
+ > The adapters are basically simple file write translation betwen the api and the file itself...
3748
+ >
3749
+ > Where as this is, wal, pages, workers, encoding up the wazoo, manifests, recovery... well, more intense recovery that the current solution. Idk... maybe I might be able to swing it... I don't know man. Don't get me wrong I've pulled off crazier shit... its the uniqueness of just how... it deals with i/o that makes it so fast in comparison... which is exactly what makes it not a great fit for an adapter... it is far faster, then the current main db... so you what that means, I ain't going to let this go to waste that would just be stupid... sigh...
3750
+
3751
+ > [!NOTE] BUILDERS LOG #19
3752
+ >
3753
+ > Not going to lie... forgot about the client -> server rpc adapter for the buses and db...
3754
+ >
3755
+ > named pipe is sooo slow though... does that mean we have to create our own transport now too?... **sigh**
3756
+ >
3757
+ > Both wal and bus run in excess of 700+ mill ops per sec, the bus does 2.1 bill... sooo... I think we have to go across a boundary for this... FUCK... while dusting off the good ol'disruptors is always fun... this means we are going to be at a minimum, bottlenecked due to serialization/encoding. While I do have access to the fastest binary encoder I could get my hands on and test... that is still short, a lot of millions...
3758
+ >
3759
+ > Build our own specialty websocket... still have to encode the payload. No matter which way we slice it...
3760
+
3761
+
3762
+ > [!NOTE] PERFORMANCE NOTES
3763
+ >
3764
+ > - replace all maps with objs, arrays even better if you have the use case for them but arrays aren't the best for real world app use cases
3765
+ > - nesting fns in iiffes seems to experience a drop in total ops, from the results I have experienced. I still do this for erverything but hot paths due to increases ergo
@@ -0,0 +1,139 @@
1
+ export type BoundaryType = 'SAME_APP' | 'SAME_NODE' | 'CROSS_NODE';
2
+ export type ContainerKind = 'WORKER' | 'PROCESS';
3
+ export interface HeaderViews {
4
+ headerInt32: Int32Array;
5
+ payloadUint8: Uint8Array;
6
+ capacity: N;
7
+ }
8
+ export interface DecodedFrame {
9
+ topicId: N;
10
+ topicName: S | undefined;
11
+ p: U8;
12
+ }
13
+ export interface RingPairDescriptor {
14
+ aToB_fast: SharedArrayBuffer;
15
+ bToA_fast: SharedArrayBuffer;
16
+ aToB_overflow: SharedArrayBuffer;
17
+ bToA_overflow: SharedArrayBuffer;
18
+ }
19
+ export interface NativeRingPairDescriptor {
20
+ name: S;
21
+ requestBytes: N;
22
+ responseBytes: N;
23
+ overflowBytes: N;
24
+ maxPayloadBytes: N;
25
+ }
26
+ export interface NativeSharedMemoryBinding {
27
+ create(name: S, requestBytes: N, responseBytes: N, overflowBytes: N, maxPayloadBytes: N): NativeRingPairDescriptor;
28
+ attach(descriptor: NativeRingPairDescriptor): RingPair;
29
+ }
30
+ export interface PeerRegistryEntry {
31
+ addressSpaceId: S;
32
+ processId: S;
33
+ boundaryType: BoundaryType;
34
+ container?: ContainerKind;
35
+ k: S;
36
+ s: S;
37
+ m: S;
38
+ r: S;
39
+ capacityBytes: N;
40
+ ring?: RingPairDescriptor;
41
+ native?: NativeRingPairDescriptor;
42
+ }
43
+ export declare class BinaryEncoder {
44
+ private static topicToId;
45
+ private static idToTopic;
46
+ static hashTopic(topic: S): N;
47
+ static getTopicId(topic: S): N;
48
+ static getTopicName(topicId: N): S | undefined;
49
+ static registerTopics(topics: AR<S>): void;
50
+ static resetRegistry(): void;
51
+ }
52
+ export declare class BinaryFrameSerializer {
53
+ private static textEncoder;
54
+ private static headerBuffer;
55
+ private static headerView;
56
+ private static headerBytes;
57
+ static encodeFrame(topic: S, p: U8 | S | Record<S, U>): U8;
58
+ static decodeFrame(frameBytes: U8): DecodedFrame;
59
+ }
60
+ export declare const HEADER_SIZE_BYTES = 64;
61
+ export declare const HEADER_IDX_WRITE_HEAD = 0;
62
+ export declare const HEADER_IDX_READ_HEAD = 1;
63
+ export declare const HEADER_IDX_MUTEX = 2;
64
+ export declare const HEADER_IDX_CAPACITY = 3;
65
+ export declare const MUTEX_UNLOCKED = 0;
66
+ export declare const MUTEX_LOCKED = 1;
67
+ export declare const SENTINEL_WRAP_MARKER = 4294967295;
68
+ export declare function createSharedDepotBuffer(capacityBytes: N): SharedArrayBuffer;
69
+ export declare function mapDepotBuffer(sab: SharedArrayBuffer): HeaderViews;
70
+ export declare function validateHeader(sab: SharedArrayBuffer): B;
71
+ export declare function calculateFrameFootprint(payloadSizeBytes: N): N;
72
+ export declare class RING_BUFFER {
73
+ private headerInt32;
74
+ private payloadUint8;
75
+ private payloadDataView;
76
+ readonly capacity: N;
77
+ constructor(sab: SharedArrayBuffer);
78
+ private acquireLock;
79
+ private releaseLock;
80
+ write(p: U8): B;
81
+ read(): U8 | null;
82
+ waitForDataAsync(timeoutMs?: N): P<'ok' | 'not-equal' | 'timed-out'>;
83
+ }
84
+ export declare function createSharedDisruptorBuffer(capacity: N, maxPayloadBytes: N): SharedArrayBuffer;
85
+ export declare function validateDisruptorHeader(sab: SharedArrayBuffer): B;
86
+ export declare class POWER_OF_TWO {
87
+ readonly capacity: N;
88
+ readonly mask: N;
89
+ readonly slotPayloadBytes: N;
90
+ readonly pids: Int32Array;
91
+ readonly values: Float64Array;
92
+ readonly lengths: Int32Array;
93
+ readonly flags: Uint8Array;
94
+ readonly payload: Uint8Array;
95
+ private readonly header;
96
+ constructor(sab: SharedArrayBuffer);
97
+ publish(pid: N, value: N, flag?: N, payload?: U8): B;
98
+ consume(handler: (pid: N, value: N, flag: N, payload: U8) => void): N;
99
+ waitForDataAsync(timeoutMs?: N): P<'ok' | 'not-equal' | 'timed-out'>;
100
+ reset(): void;
101
+ }
102
+ export declare class HybridChannel {
103
+ private readonly fast;
104
+ private readonly overflow;
105
+ constructor(fast: POWER_OF_TWO, overflow: RING_BUFFER);
106
+ publish(topicId: N, payload: U8, value?: N, flag?: N): B;
107
+ consume(handler: (topicId: N, payload: U8, value: N, flag: N) => void): N;
108
+ drainLoop(handler: (topicId: N, payload: U8, value: N, flag: N) => void, signal?: AbortSignal): Promise<void>;
109
+ }
110
+ export declare class RingPair {
111
+ readonly tx: HybridChannel;
112
+ readonly rx: HybridChannel;
113
+ readonly descriptor: RingPairDescriptor;
114
+ private constructor();
115
+ static create(capacity: N, maxPayloadBytes: N, overflowCapacityBytes: N): RingPair;
116
+ static attach(descriptor: RingPairDescriptor): RingPair;
117
+ }
118
+ export declare const NATIVE_SHARED_MEMORY_BRIDGE: {
119
+ create: (name: S, requestBytes: N, responseBytes: N, overflowBytes: N, maxPayloadBytes: N) => NativeRingPairDescriptor;
120
+ attach: (descriptor: NativeRingPairDescriptor) => RingPair;
121
+ };
122
+ type BusSend = (msg: A, k: S, s: S, m: S, r: S) => void;
123
+ type BusSub = (handler: A, k: S, s: S, m: S, r: S) => void;
124
+ export declare class ControlPlaneBootstrapper {
125
+ private localAddressSpaceId;
126
+ private k;
127
+ private s;
128
+ private m;
129
+ private r;
130
+ private onPromote;
131
+ private send;
132
+ private sub;
133
+ private peerRegistry;
134
+ constructor(localAddressSpaceId: S, k: S, s: S, m: S, r: S, onPromote: (peer: PeerRegistryEntry, pair: RingPair) => void, send: BusSend, sub: BusSub);
135
+ announceDepot(capacity: N, maxPayloadBytes: N, overflowCapacityBytes: N): RingPair;
136
+ private promoteRouteToDataPlane;
137
+ }
138
+ export {};
139
+ //# sourceMappingURL=RULE_OF_2_same_node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RULE_OF_2_same_node.d.ts","sourceRoot":"","sources":["../../src/bus_db_rpc/RULE_OF_2_same_node.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AACnE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,CAAC;AACjD,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,UAAU,CAAC;IACzB,QAAQ,EAAE,CAAC,CAAC;CACb;AACD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,CAAC,CAAC;IACX,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC;IACzB,CAAC,EAAE,EAAE,CAAC;CACP;AACD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,iBAAiB,CAAC;CAClC;AACD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,CAAC,CAAC;IACR,YAAY,EAAE,CAAC,CAAC;IAChB,aAAa,EAAE,CAAC,CAAC;IACjB,aAA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