Skip to content

Commit cce2b06

Browse files
committed
feat: tcmalloc and cache-line alignment
1 parent 30a966e commit cce2b06

28 files changed

Lines changed: 154 additions & 71 deletions

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Build
2+
3+
# run the vanilla build pipeline on commits to feature branches, or PRs on master
4+
5+
on:
6+
push:
7+
branches:
8+
- "*"
9+
pull_request:
10+
branches: [ master ]
11+
12+
13+
jobs:
14+
call-reusable:
15+
uses: ./.github/workflows/reusable_build.yml

.github/workflows/commits.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
name: Daily
1+
name: Nightly
2+
3+
# run the vanilla build pipeline every night on the master branch
24

35
on:
46
schedule:
@@ -7,6 +9,6 @@ on:
79

810
jobs:
911
call-reusable:
10-
uses: ./.github/workflows/clean_build_test.yml
12+
uses: ./.github/workflows/reusable_build.yml
1113
with:
1214
ref: ${{ 'master' }}

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
name: Release
22

3+
# run the Release pipeline when a release is created, and attach artifacts
4+
35
on:
46
release:
57
types: [published] # Triggers when a release is published
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
name: Reusable Build Workflow
22

3+
# reusable build pipeline
4+
# creates a Debug build, and runs assorted tests
5+
36
on:
47
workflow_call:
58
inputs:
69
ref:
710
description: 'Git reference to checkout'
811
required: false
912
type: string
10-
11-
# workflow_dispatch: # Allows manual triggering
13+
workflow_dispatch: # Allows manual run from GitHub UI
1214

1315
jobs:
1416
build_and_test:

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ find_package(Boost REQUIRED)
3434
find_package(concurrentqueue REQUIRED)
3535
find_package(efsw REQUIRED)
3636
find_package(ftxui REQUIRED)
37+
find_package(gperftools REQUIRED)
3738
find_package(Microsoft.GSL REQUIRED)
3839
find_package(GTest REQUIRED)
3940
find_package(OpenSSL REQUIRED)
@@ -47,6 +48,7 @@ target_link_libraries(traderlib PUBLIC
4748
concurrentqueue::concurrentqueue
4849
efsw::efsw
4950
ftxui::ftxui
51+
gperftools::gperftools
5052
Microsoft.GSL::GSL
5153
OpenSSL::SSL
5254
OpenSSL::Crypto

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ NB: this app uses `make` as a recipe book, but it's not essential:
8080
- OrderMassCancelRequest on error
8181
- quickfix database vs fix8 equivalent
8282
- ✅ subscribe to price updates
83+
- ✅ use a precise number type for money
8384
- create a basic trading signal (e.g. standard deviations)
84-
- use a precise number type for money
8585
- fire an order
86-
- test in the Binance test environment
86+
- test in the Binance test environment
8787
- momentum indicators
8888
- throughput indicators (messages/sec)
8989
- orders
@@ -151,12 +151,13 @@ NB: this app uses `make` as a recipe book, but it's not essential:
151151
- FTXUI snapshot testing
152152
- performance
153153
- ✅ store prices and sizes as integrals (ticks as `uint64_t`) for performance
154+
- ✅ cache line alignment
154155
- release compile flags
155156
- profiling (valgrind/cachegrind)
156-
- gperftools
157157
- profile-guided optimization (pgo)
158158
- load test with mocked FIX server
159-
- tcmalloc / gperftools
159+
- tcmalloc (Full/Minimal) / gperftools
160+
- profiling tcmalloc
160161
- latency
161162
- sparse arrays & flat matrix
162163
- memory-mapped files

conan.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"libsodium/1.0.20#d2baa92ed999abe295ff63e2ee25b4f3%1743063880.072",
1010
"libbacktrace/cci.20210118#a7691bfccd8caaf66309df196790a5a1%1722218217.276",
1111
"gtest/1.17.0#5224b3b3ff3b4ce1133cbdd27d53ee7d%1755784855.585",
12+
"gperftools/2.17.2#1de28b5116961a072cf9a2d62f231d2a%1759579795.648",
1213
"ftxui/6.0.2#1b49d899f377591328fd17df1b3fd98e%1744735500.697",
1314
"fmt/11.2.0#579bb2cdf4a7607621beea4eb4651e0f%1746298708.362",
1415
"efsw/1.4.1#a4dc44b2fa9fa5a55081e365b1301d4c%1731488680.092",

conanfile.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ boost/1.88.0
44
concurrentqueue/1.0.4
55
efsw/1.4.1
66
ftxui/6.0.2
7-
ms-gsl/4.2.0
7+
gperftools/2.17.2
88
gtest/1.17.0
9+
ms-gsl/4.2.0
910
openssl/3.5.2
1011
quickfix/1.15.1
1112
libsodium/1.0.20

src/binance/auth.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#pragma once
22

33
#include <mutex>
4+
#include <new>
45
#include <string>
56
#include <vector>
67

8+
#include "../utils/env.h"
79
#include "iauth.h"
810

911
namespace binance {
@@ -41,7 +43,7 @@ class Auth final : public IAuth {
4143
private:
4244
// when authenticating with Binance, each session authenticates independently,
4345
// and in parallel. requires synchronisation because of file access.
44-
mutable std::mutex mutex_;
46+
alignas(utils::Env::CACHE_LINE_SIZE) mutable std::mutex mutex_;
4547

4648
std::string& api_key_;
4749
std::string& private_pem_path_;

0 commit comments

Comments
 (0)