Skip to content

Commit a195a89

Browse files
committed
UPD | fast build
1 parent 7a2a5cb commit a195a89

13 files changed

+93
-44
lines changed

CMakeLists.txt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ else ()
973973
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
974974
endif ()
975975

976+
set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ON)
976977
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
977978

978979
include(GenerateExportHeader)
@@ -1232,14 +1233,41 @@ if (MANAPIHTTP_NGHTTP3_DEPENDENCY_FETCH)
12321233
add_dependencies(${PROJECT_NAME} libnghttp3)
12331234
endif ()
12341235

1236+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
1237+
target_precompile_headers(${PROJECT_NAME} PRIVATE
1238+
<vector>
1239+
<string>
1240+
<map>
1241+
<unordered_map>
1242+
<memory>
1243+
<algorithm>
1244+
<filesystem>
1245+
<cstring>
1246+
<functional>
1247+
<deque>
1248+
<limits>
1249+
)
1250+
endif()
1251+
12351252
if(BUILD_SHARED_LIBS)
12361253
message(STATUS "shared build")
12371254
else ()
12381255
message(STATUS "static build")
12391256
set(OPENSSL_USE_STATIC_LIBS TRUE)
12401257
endif ()
12411258

1242-
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14)
1259+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1260+
target_compile_options(${PROJECT_NAME} PRIVATE -pipe -fno-semantic-interposition)
1261+
if (UNIX)
1262+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
1263+
endif()
1264+
endif()
1265+
1266+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
1267+
target_compile_options(${PROJECT_NAME} PRIVATE -fno-stack-check -fno-address-sanitizer-use-after-scope)
1268+
endif()
1269+
1270+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14)
12431271
if (WIN32)
12441272

12451273
else ()
@@ -1251,6 +1279,10 @@ else()
12511279
endif ()
12521280
endif()
12531281

1282+
if(MSVC)
1283+
target_compile_options(myTarget PRIVATE /MP)
1284+
endif()
1285+
12541286
# Include public headers from the folder
12551287
target_include_directories (${PROJECT_NAME} PRIVATE include)
12561288
target_include_directories (${PROJECT_NAME} PRIVATE ${CMAKE_BINARY_DIR}/include)

main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class GreeterClient {
8282
// Assembles the client's payload, sends it and presents the response back
8383
// from the server.
8484
manapi::future<manapi::error::status_or<std::string>> SayHello(const std::string& user) {
85-
using promise = manapi::async::promise_sync<manapi::error::status_or<std::string>>;
85+
typedef manapi::async::promise_sync<manapi::error::status_or<std::string>> promise;
8686
// Data we are sending to the server.
8787
helloworld::HelloRequest request;
8888
request.set_name(user);

src/ManapiHttp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ manapi::future<manapi::error::status> manapi::net::http::server::start() {
8181

8282
co_await this->init_pool_();
8383

84-
using promise = async::promise_sync<error::status>;
84+
typedef async::promise_sync<error::status> promise;
8585
co_return co_await promise([this, &lk] (const promise::resolve_t& resolve, const promise::reject_t& reject) -> void {
8686
auto res = this->pool_([&lk, resolve] () mutable -> void {
8787
lk.call();

src/compress/ManapiHPack.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#include "../include/ManapiUtils.hpp"
99
#include "http/ManapiHttpUtils.hpp"
1010

11+
#ifdef T
12+
# define MANAPI_HPACK_T_PREV T
13+
#endif
14+
#ifdef F
15+
# define MANAPI_HPACK_F_PREV F
16+
#endif
1117
#define T true
1218
#define F false
1319

@@ -1250,3 +1256,14 @@ namespace manapi::compress::hpack {
12501256
return std::move(m_buf);
12511257
}
12521258
}
1259+
1260+
#undef T
1261+
#undef F
1262+
#ifdef MANAPI_HPACK_T_PREV
1263+
# define T MANAPI_HPACK_T_PREV
1264+
# undef MANAPI_HPACK_T_PREV
1265+
#endif
1266+
#ifdef MANAPI_HPACK_F_PREV
1267+
# define F MANAPI_HPACK_F_PREV
1268+
# undef MANAPI_HPACK_F_PREV
1269+
#endif

src/crypto/ManapiCryptoUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ manapi::future<manapi::error::status> manapi::crypto::async_random_string(char *
7575
if (!len)
7676
co_return error::status_ok();
7777

78-
using promise = manapi::async::promise_sync<manapi::error::status>;
78+
typedef manapi::async::promise_sync<manapi::error::status> promise;
7979
manapi::error::status res;
8080
try {
8181
res = co_await promise ([&] (promise::resolve_t resolve, promise::reject_t reject) mutable

src/fs/ManapiFilesystem.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bool async_fs_operation_result_error (std::shared_ptr<manapi::ev::fs> &w, typena
5353
}
5454

5555
template<typename T>
56-
using async_fs_operation_event_cb = std::move_only_function<void(std::shared_ptr<manapi::ev::fs>, typename manapi::async::promise_sync<T>::resolve_t&, manapi::async::cancellation_action &cancellation)>;
56+
using async_fs_operation_event_cb = std::move_only_function<void(std::shared_ptr<manapi::ev::fs>, typename manapi::async::promise_sync<T>::resolve_t&, manapi::async::cancellation_action &cancellation)>;
5757

5858
template<typename T>
5959
void async_fs_operation_event_handler (std::shared_ptr<manapi::ev::fs> w, typename manapi::async::promise_sync<T>::resolve_t resolve, manapi::async::cancellation_action cancellation, async_fs_operation_event_cb<T> &event_cb) {
@@ -85,7 +85,7 @@ struct async_fs_operation_deleter {
8585
template<typename T>
8686
manapi::future<T> async_fs_operation (std::move_only_function<bool(std::shared_ptr<manapi::ev::fs> w)> start_cb,
8787
async_fs_operation_event_cb<T> event_cb, manapi::async::cancellation_action cancellation) {
88-
using promise_sync = manapi::async::promise_sync<T>;
88+
typedef manapi::async::promise_sync<T> promise_sync;
8989
async_fs_operation_deleter<T> t {};
9090

9191
t.c = &cancellation;
@@ -129,7 +129,7 @@ manapi::future<T> async_fs_operation (std::move_only_function<bool(std::shared_p
129129
}
130130

131131
manapi::future<manapi::sys_error::status> async_fs_simple_operation (std::move_only_function<bool(std::shared_ptr<manapi::ev::fs> w)> start_cb, manapi::async::cancellation_action cancellation) {
132-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status>;
132+
typedef manapi::async::promise_sync<manapi::sys_error::status> promise_sync;
133133

134134
co_return co_await async_fs_operation<manapi::sys_error::status>(std::move(start_cb),
135135
[](std::shared_ptr<manapi::ev::fs> w,
@@ -200,7 +200,7 @@ manapi::future<manapi::sys_error::status_or<std::chrono::system_clock::time_poin
200200
}
201201

202202
manapi::future<manapi::sys_error::status> manapi::filesystem::async_mkdir(std::string path, int mode, bool recursive, manapi::async::cancellation_action cancellation) {
203-
using promise_sync = manapi::async::promise_sync<sys_error::status>;
203+
typedef manapi::async::promise_sync<sys_error::status> promise_sync;
204204

205205
if (recursive) {
206206
auto parts = manapi::string::split(path, path::delimiter);
@@ -253,7 +253,7 @@ manapi::future<manapi::sys_error::status> manapi::filesystem::async_mkdir(std::s
253253
}
254254

255255
manapi::future<manapi::sys_error::status_or<manapi::ev::file>> manapi::filesystem::async_open(std::string path, int flags, int mode, manapi::async::cancellation_action cancellation) {
256-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status_or<ev::file>>;
256+
typedef manapi::async::promise_sync<manapi::sys_error::status_or<ev::file>> promise_sync;
257257

258258
auto fileno = co_await async_fs_operation<manapi::sys_error::status_or<ev::file>>([path = std::move(path), flags, mode] (std::shared_ptr<ev::fs> w)
259259
-> bool {
@@ -269,7 +269,7 @@ manapi::future<manapi::sys_error::status_or<manapi::ev::file>> manapi::filesyste
269269
}
270270

271271
manapi::future<manapi::sys_error::status> manapi::filesystem::async_close(ev::file file, async::cancellation_action cancellation) {
272-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status>;
272+
typedef manapi::async::promise_sync<manapi::sys_error::status> promise_sync;
273273

274274
manapi_log_trace(manapi::debug::LOG_TRACE_LOW, "fs:fd %d close", file);
275275

@@ -422,7 +422,7 @@ manapi::future<manapi::sys_error::status_or<std::string>> manapi::filesystem::as
422422
}
423423

424424
manapi::future<manapi::sys_error::status_or<ssize_t>> manapi::filesystem::async_write(ev::file file, ev::buff_t *buff, uint32_t nbuff, int64_t offset, async::cancellation_action cancellation) {
425-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status_or<ssize_t>>;
425+
typedef manapi::async::promise_sync<manapi::sys_error::status_or<ssize_t>> promise_sync;
426426

427427
if (!nbuff)
428428
co_return 0;
@@ -559,7 +559,7 @@ manapi::future<manapi::sys_error::status_or<ssize_t>> manapi::filesystem::async_
559559
}
560560

561561
manapi::future<manapi::sys_error::status_or<ssize_t>> manapi::filesystem::async_read(ev::file file, ev::buff_t *buff, uint32_t nbuff, int64_t offset, async::cancellation_action cancellation) {
562-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status_or<ssize_t>>;
562+
typedef manapi::async::promise_sync<manapi::sys_error::status_or<ssize_t>> promise_sync;
563563

564564
if (!nbuff)
565565
co_return 0;
@@ -727,7 +727,7 @@ manapi::future<manapi::sys_error::status_or<ssize_t>> manapi::filesystem::async_
727727
}
728728

729729
manapi::future<manapi::sys_error::status> manapi::filesystem::async_stat(std::string path, std::move_only_function<void(ev::stat_t *data)> callback, async::cancellation_action cancellation) {
730-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status>;
730+
typedef manapi::async::promise_sync<manapi::sys_error::status> promise_sync;
731731

732732
co_return co_await async_fs_operation<manapi::sys_error::status>([path = std::move(path)] (std::shared_ptr<ev::fs> w)
733733
-> bool {
@@ -749,7 +749,7 @@ manapi::future<manapi::sys_error::status> manapi::filesystem::async_stat(std::st
749749
}
750750

751751
manapi::future<manapi::sys_error::status> manapi::filesystem::async_fstat(ev::file file, std::move_only_function<void(ev::stat_t *data)> callback, async::cancellation_action cancellation) {
752-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status>;
752+
typedef manapi::async::promise_sync<manapi::sys_error::status> promise_sync;
753753

754754
co_return co_await async_fs_operation<manapi::sys_error::status>([file] (std::shared_ptr<ev::fs> w)
755755
-> bool {
@@ -888,7 +888,7 @@ manapi::future<manapi::sys_error::status> manapi::filesystem::async_closedir (ma
888888
}
889889

890890
manapi::future<manapi::sys_error::status> manapi::filesystem::async_statfs (std::string path, std::move_only_function<void(ev::statfs_t *data)> callback, async::cancellation_action cancellation) {
891-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status>;
891+
typedef manapi::async::promise_sync<manapi::sys_error::status> promise_sync;
892892

893893
co_return co_await async_fs_operation<manapi::sys_error::status>([path = std::move(path)] (std::shared_ptr<ev::fs> w)
894894
-> bool {
@@ -930,7 +930,7 @@ manapi::future<manapi::sys_error::status> manapi::filesystem::async_fchmod (ev::
930930
}
931931

932932
manapi::future<manapi::sys_error::status> manapi::filesystem::async_access (std::string path, int mode, async::cancellation_action cancellation) {
933-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status>;
933+
typedef manapi::async::promise_sync<manapi::sys_error::status> promise_sync;
934934

935935
co_return co_await async_fs_operation<manapi::sys_error::status>([path = std::move(path), mode] (std::shared_ptr<ev::fs> w)
936936
-> bool {
@@ -976,7 +976,7 @@ manapi::future<manapi::sys_error::status> manapi::filesystem::async_fdatasync(ev
976976
}
977977

978978
manapi::future<manapi::sys_error::status_or<manapi::ev::dir_t *>> manapi::filesystem::async_opendir(std::string path, async::cancellation_action cancellation) {
979-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status_or<manapi::ev::dir_t *>>;
979+
typedef manapi::async::promise_sync<manapi::sys_error::status_or<manapi::ev::dir_t *>> promise_sync;
980980

981981
co_return co_await async_fs_operation<manapi::sys_error::status_or<manapi::ev::dir_t *>>([path = std::move(path)] (std::shared_ptr<ev::fs> w)
982982
-> bool {
@@ -991,7 +991,7 @@ manapi::future<manapi::sys_error::status_or<manapi::ev::dir_t *>> manapi::filesy
991991
}
992992

993993
manapi::future<manapi::sys_error::status_or<std::string>> manapi::filesystem::async_readlink (std::string path, async::cancellation_action cancellation) {
994-
using promise_sync = manapi::async::promise_sync<sys_error::status_or<std::string>>;
994+
typedef manapi::async::promise_sync<sys_error::status_or<std::string>> promise_sync;
995995

996996
co_return co_await async_fs_operation<manapi::sys_error::status_or<std::string>>([path = std::move(path)] (std::shared_ptr<ev::fs> w)
997997
-> bool {
@@ -1006,7 +1006,7 @@ manapi::future<manapi::sys_error::status_or<std::string>> manapi::filesystem::as
10061006
}
10071007

10081008
manapi::future<manapi::sys_error::status_or<std::string>> manapi::filesystem::async_realpath (std::string path, async::cancellation_action cancellation) {
1009-
using promise_sync = manapi::async::promise_sync<sys_error::status_or<std::string>>;
1009+
typedef manapi::async::promise_sync<sys_error::status_or<std::string>> promise_sync;
10101010

10111011
co_return co_await async_fs_operation<manapi::sys_error::status_or<std::string>>([path = std::move(path)] (std::shared_ptr<ev::fs> w)
10121012
-> bool {
@@ -1032,7 +1032,7 @@ manapi::future<manapi::sys_error::status> manapi::filesystem::async_fchown(ev::f
10321032
}
10331033

10341034
manapi::future<manapi::sys_error::status_or<std::string>> manapi::filesystem::async_mkdtemp(std::string tpl, async::cancellation_action cancellation) {
1035-
using promise_sync = manapi::async::promise_sync<manapi::sys_error::status_or<std::string>>;
1035+
typedef manapi::async::promise_sync<manapi::sys_error::status_or<std::string>> promise_sync;
10361036

10371037
co_return co_await async_fs_operation<manapi::sys_error::status_or<std::string>>([tpl = std::move(tpl)] (std::shared_ptr<ev::fs> w)
10381038
-> bool {
@@ -1048,8 +1048,8 @@ manapi::future<manapi::sys_error::status_or<std::string>> manapi::filesystem::as
10481048
}
10491049

10501050
manapi::future<manapi::sys_error::status_or<std::pair<std::string, manapi::ev::file>>> manapi::filesystem::async_mkstemp(std::string tpl, async::cancellation_action cancellation) {
1051-
using val = sys_error::status_or<std::pair<std::string, manapi::ev::file>>;
1052-
using promise_sync = manapi::async::promise_sync<val>;
1051+
typedef sys_error::status_or<std::pair<std::string, manapi::ev::file>> val;
1052+
typedef manapi::async::promise_sync<val> promise_sync;
10531053

10541054
co_return co_await async_fs_operation<val>([tpl = std::move(tpl)] (std::shared_ptr<ev::fs> w)
10551055
-> bool {
@@ -1064,7 +1064,7 @@ manapi::future<manapi::sys_error::status_or<std::pair<std::string, manapi::ev::f
10641064
}
10651065

10661066
manapi::future<manapi::sys_error::status_or<std::size_t>> manapi::filesystem::async_scandir (std::string path, int flags, std::move_only_function<void(ev::dir_t *dir, std::size_t result)> callback, async::cancellation_action cancellation) {
1067-
using promise_sync = manapi::async::promise_sync<sys_error::status_or<std::size_t>>;
1067+
typedef manapi::async::promise_sync<sys_error::status_or<std::size_t>> promise_sync;
10681068

10691069
co_return co_await async_fs_operation<sys_error::status_or<std::size_t>>([path = std::move(path), flags] (std::shared_ptr<ev::fs> w)
10701070
-> bool {
@@ -1082,7 +1082,7 @@ manapi::future<manapi::sys_error::status_or<std::size_t>> manapi::filesystem::as
10821082
}
10831083

10841084
manapi::future<manapi::sys_error::status_or<std::size_t>> manapi::filesystem::async_readdir (ev::dir_t *dir, std::move_only_function<void(ev::dir_t *, std::size_t)> callback, async::cancellation_action cancellation) {
1085-
using promise_sync = manapi::async::promise_sync<sys_error::status_or<std::size_t>>;
1085+
typedef manapi::async::promise_sync<sys_error::status_or<std::size_t>> promise_sync;
10861086

10871087
co_return co_await async_fs_operation<sys_error::status_or<std::size_t>>([dir] (std::shared_ptr<ev::fs> w)
10881088
-> bool {

src/http/ManapiHttp2Interface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int default_wrk_http2_cleanup (manapi::net::worker::connection *conn, manapi::ne
1616
return 0;
1717
}
1818

19-
static void wrk_close_connection ( manapi::net::worker::shared_conn conn, manapi::net::worker::shared_conn sconn, manapi::net::worker::base *w, bool ok) MANAPIHTTP_NOEXCEPT {
19+
static void wrk_close_conn2 ( manapi::net::worker::shared_conn conn, manapi::net::worker::shared_conn sconn, manapi::net::worker::base *w, bool ok) MANAPIHTTP_NOEXCEPT {
2020
MANAPIHTTP_MUST_ALLOC_START
2121
manapi::async::current()->etaskpool()->append_static_task(
2222
[w = std::move(w), ok, conn = std::move(conn), sconn = std::move(sconn)] () -> void {
@@ -123,7 +123,7 @@ int default_wrk_http2(const manapi::net::worker::shared_conn &conn, int flags, c
123123
req_ptr, std::make_unique<manapi::net::http::internal::cont_callback_cb_t>(
124124
[w, sconn = s->second, conn] (bool ok) mutable
125125
-> void {
126-
wrk_close_connection (conn, sconn, w, ok);
126+
wrk_close_conn2 (conn, sconn, w, ok);
127127
}));
128128

129129
// this->event_on(conn, std::unique_ptr<worker_watcher_cb>(nullptr));
@@ -134,15 +134,15 @@ int default_wrk_http2(const manapi::net::worker::shared_conn &conn, int flags, c
134134
}
135135
catch (std::exception const &e) {
136136
manapi_log_error("%s:%s failed due to %s", "http2", "new conn", e.what());
137-
wrk_close_connection(conn, s->second, w, false);
137+
wrk_close_conn2(conn, s->second, w, false);
138138
}
139139
});
140140

141141
sdata->flags |= manapi::net::http::HTTP2_STREAM_STARTED;
142142
}
143143
catch (std::exception const &e ) {
144144
manapi_log_error("%s:%s failed due to %s", "http2", "new conn", e.what());
145-
wrk_close_connection(conn, s->second, w, false);
145+
wrk_close_conn2(conn, s->second, w, false);
146146
}
147147

148148

src/http/ManapiHttpPool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ manapi::future<manapi::error::status> manapi::net::http_pool::stop() {
3434
auto lk = co_await this->mx->lock_guard();
3535
manapi_log_trace(debug::LOG_TRACE_MEDIUM, "shutdown socket");
3636
if (this->worker) {
37-
using promise = manapi::async::promise_sync<void>;
37+
typedef manapi::async::promise_sync<void> promise;
3838
co_await promise ([this] (promise::resolve_t resolve, promise::reject_t reject) -> void {
3939
try {
4040
this->worker->stop(std::move(resolve));

src/http/ManapiNgHttp3Interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static int ng_wrk_http3(const manapi::net::worker::shared_conn &stream, int flag
307307
}
308308

309309
if (flags & manapi::ev::WRITE) {
310-
//assert(s->top->send.deque);
310+
//assert(s->top->send.deque);an c
311311
if (auto rhs = nghttp3_conn_unblock_stream (s->ctx->ctx.get(), stream_id)) {
312312
manapi_log_trace(manapi::debug::LOG_TRACE_HIGH, "%s failed due to %s", "nghttp3_conn_unblock_stream", nghttp3_strerror(rhs));
313313
goto err;

0 commit comments

Comments
 (0)