Skip to content

Commit

Permalink
jemalloc: avoid bottlenecks with C threads
Browse files Browse the repository at this point in the history
Current default jemalloc settings:
```
╭──────────────────────────────────────┬───────────────────────────┬───────────────────────────╮
│name                                  │  minor-allocated          │  monotonic clock/op       │
├──────────────────────────────────────┼───────────────────────────┼───────────────────────────┤
│  concurrent semaphore + sleep fix:1  │            14.4615 mnw/run│          40.7085 ms/op/run│
│  concurrent semaphore + sleep fix:8  │            76.0000 mnw/run│          39.6229 ms/op/run│
╰──────────────────────────────────────┴───────────────────────────┴───────────────────────────╯
```

A flamegraph shows that 'sha512_crypt_r' spends >90% of time in jemalloc and not on hashing.

With 'tcache:true'
```
╭──────────────────────────────────────┬───────────────────────────┬───────────────────────────╮
│name                                  │  minor-allocated          │  monotonic clock/op       │
├──────────────────────────────────────┼───────────────────────────┼───────────────────────────┤
│  concurrent semaphore + sleep fix:1  │            10.1538 mnw/run│           1.6766 ms/op/run│
│  concurrent semaphore + sleep fix:8  │            67.3600 mnw/run│           0.4431 ms/op/run│
╰──────────────────────────────────────┴───────────────────────────┴───────────────────────────╯
```

Without jemalloc:
```
╭──────────────────────────────────────┬───────────────────────────┬───────────────────────────╮
│name                                  │  minor-allocated          │  monotonic clock/op       │
├──────────────────────────────────────┼───────────────────────────┼───────────────────────────┤
│  concurrent semaphore + sleep fix:1  │            10.0488 mnw/run│           1.5649 ms/op/run│
│  concurrent semaphore + sleep fix:8  │            67.1111 mnw/run│           0.3858 ms/op/run│
╰──────────────────────────────────────┴───────────────────────────┴───────────────────────────╯
```

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Oct 12, 2023
1 parent ed16f35 commit 490ea9a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/xapi.service
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Conflicts=shutdown.target
[Service]
User=root
Environment="LD_PRELOAD=/usr/lib64/libjemalloc.so.1"
Environment="MALLOC_CONF=narenas:1,tcache:false,lg_dirty_mult:22"
Environment="MALLOC_CONF=narenas:1,tcache:true,lg_dirty_mult:22"
Type=simple
Restart=on-failure
ExecStart=@LIBEXECDIR@/xapi-init start
Expand Down

0 comments on commit 490ea9a

Please sign in to comment.