Skip to content

Conversation

@edwintorok
Copy link
Contributor

We were converting events to RPC.t twice: first using the internal OCaml names, and then mapping them back to some "wire" names. This can be done a lot more simply by generating the wire names in the first place (the ppx support overriding the wire name of fields).

ministat confirms an improvement on rpc_of_event:

      N           Min           Max        Median           Avg        Stddev
x  922     440.79126     46094.975     467.83727     563.79259     1676.0843
+ 1131     51.346821     33407.866     58.715393     115.98006     1105.4178
  Difference at 95.0% confidence
            -447.813 +/- 120.966
             -79.4286% +/- 13.1488%
           (Student's t, pooled s = 1390.95)

Atomic is also faster than an integer wrapped with a mutex:

Mutex+incr (ns):
 { monotonic-clock per run = 32.272091 (confidence: 32.365531 to 32.170138);
 r² = Some 0.999441 }
Atomic.incr (ns):
 { monotonic-clock per run = 2.938678 (confidence: 2.944486 to 2.933688);
   r² = Some 0.999857 }

I've added some new new benchmarks for event field conversion, atomic vs mutex and DB field writes.

edwintorok added 8 commits May 9, 2025 18:08
No functional change

Signed-off-by: Edwin Török <[email protected]>
No functional change

Signed-off-by: Edwin Török <[email protected]>
Use an attribute to change the name of the fields instead of serializing with one name,
and then mapping to the other.

`ministat` confirms an improvement on `rpc_of_event`:
```
    N           Min           Max        Median           Avg        Stddev
x 922     440.79126     46094.975     467.83727     563.79259     1676.0843
+ 1131     51.346821     33407.866     58.715393     115.98006     1105.4178
Difference at 95.0% confidence
        -447.813 +/- 120.966
        -79.4286% +/- 13.1488%
        (Student's t, pooled s = 1390.95)
```

Signed-off-by: Edwin Török <[email protected]>
Atomic has lower overhead, and can be used for simple situations (incrementing an integer, setting a boolean).

```
Mutex+incr (ns):
 { monotonic-clock per run = 32.272091 (confidence: 32.365531 to 32.170138);
   r² = Some 0.999441 }
Atomic.incr (ns):
 { monotonic-clock per run = 2.938678 (confidence: 2.944486 to 2.933688);
   r² = Some 0.999857 }
```


No functional change

Signed-off-by: Edwin Török <[email protected]>
No measurable performance change, but this makes it clearer for deadlock detection algorithms
that we are waiting to acquire a lock.
It'll also make it clearer for OCaml 5's thread sanitizer that values are modified with a lock held.

Signed-off-by: Edwin Török <[email protected]>
No functional change

Signed-off-by: Edwin Török <[email protected]>
The double ref is not needed, replace it with an Atomic.t

No functional change.

Signed-off-by: Edwin Török <[email protected]>
@last-genius
Copy link
Contributor

There is a bit of weirdness again, probably with jj doing something so that the last commit links to changes from 5 commits instead:

f2dcc67

Looks good otherwise

Copy link
Contributor

@lindig lindig left a comment

Choose a reason for hiding this comment

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

Looks good. I see this mostly as a move from references to Atomic.

@psafont psafont added this pull request to the merge queue May 13, 2025
Merged via the queue into xapi-project:master with commit 418b610 May 13, 2025
17 checks passed
github-merge-queue bot pushed a commit that referenced this pull request May 15, 2025
…me (#6462)

Builds on top of #6461

Benchmark results are on individual commits.

The most significant one:

`ministat` confirms a speedup:
```
       Db.Pool.get_all_records  :
           N           Min           Max        Median           Avg        Stddev
       x 432     54115.256     493532.78      56048.42     57937.384      24117.68
       + 524     22642.778     333257.36     23595.495     24679.258     15206.708
       Difference at 95.0% confidence
               -33258.1 +/- 2513.99
               -57.4036% +/- 2.90374%
               (Student's t, pooled s = 19737.2)

       >>>>  Db.VM.set_NVRAM  :
           N           Min           Max        Median           Avg        Stddev
       x 132         36794     2355369.4     1095736.6     1107222.1      298247.5
       + 168     49167.417     1485278.1     678231.31     685636.89     161480.92
       Difference at 95.0% confidence
               -421585 +/- 52835.6
               -38.0759% +/- 3.54275%
               (Student's t, pooled s = 231767)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants