SlideShare uma empresa Scribd logo
1 de 34
Baixar para ler offline
1
ceph::errorator<>
throw/catch-free, compile time-checked
exceptions for seastar::future<>
Radosław Zarzyński
Seastar Summit 2019
2019.11.04
2
Error handling with seastar::future
● future_state_base is discriminated union between
promised value and std::exception_ptr.
● Signaling:
○ throw Exception() or
○ seastar::make_exception_future<T…>(Exception&& ex) or
○ Its second variant taking std::exception_ptr.
● Inspecting:
○ handle_exception_type<ExceptionTakingFunc>(...) or
○ handle_exception(...) and raw std::exception_ptr.
3
● Throwing on current implementation imposes costs both in the terms of
○ performance (computational resources) and
○ scalability (number of threads throwing the same time).
● The scalability limitations have been only partially tackled down in GCC.
Throwing still imposes locking.
● Seastar workarounds the issue with the exception scalability hack at the price
of assuming no dlopen() after the initialization phase.
● The hack should be disabled in crimson as loading plugins is necessary to
fully mimic the interfaces of current OSD’s interfaces.
What’s wrong with throwing?
4
● Zero-cost exceptions tend to be
slow when it comes to throwing...
● … but without the exception hack
they are also not scalable.
● The make_exception_future
path on GCC is throw-free after
Gleb Natapov's optimization for
std::make_exception_ptr
implementation in libstdc++.
● Programmer is not enforced to
use the optimized path – someone
still can throw.
● Is there better way than review?
Signaling
try
{
- throw __ex;
+#if __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI
+ void *__e =
__cxxabiv1::__cxa_allocate_exception(sizeof(_Ex));
+ (void)__cxxabiv1::__cxa_init_primary_exception(__e,
+ const_cast<std::type_info*>(&typeid(__ex)),
+ __exception_ptr::__dest_thunk<_Ex>);
+ new (__e) _Ex(__ex);
+ return exception_ptr(__e);
+#else
+ throw __ex;
+#endif
}
catch(...)
5
● handle_exception_type()
is not suitable for a hot path
due to rethrowing
● handle_exception() doesn’t
solve the problem of
differentiating behavior basing
on exception type; it just
delegates it outside.
● Is there a throw-free approach
to match ExceptionA but not
ExceptionB?
std::tuple<T...> get() const& {
// …
if (_u.st >= state::exception_min)
std::rethrow_exception(_u.ex);
// ...
}
template <typename Func>
future<T...> handle_exception_type(Func&& func) noexcept {
// ...
return then_wrapped([func = std::forward<Func>(func)]
(auto&& fut) mutable -> future<T...>
{
try {
return make_ready_future<T...>(fut.get());
} catch(ex_type& ex) {
return futurize<func_ret>::apply(func, ex);
}
Inspecting
6
● Allows for fast, throw-free type inspection of std::exception_ptr:
*ep.__cxa_exception_type() == typeid(ExceptionA);
● Compiler extension present in both GCC and Clang.
● For other compilers can be mimicked on top of try/catch.
__cxa_exception_type()
class exception_ptr {
const std::type_info* __cxa_exception_type() const;
}
7
● The expression does exact matching while it’s perfectly
fine to:
fut.handle_exception_type([] (ExceptionBase&) {});
● So maybe handle_exception_exact_type()?
Drop-in replacement for handle_exception_type?
8
seastar::future<ceph::bufferptr> CyanStore::get_attr(
CollectionRef ch,
const ghobject_t& oid,
std::string_view name) const;
What are the errors here?
● What will happen if object does not exist?
● How no-object is distinguished from no-key?
9
seastar::future<ceph::bufferptr> CyanStore::get_attr(
// …
{
auto o = c->get_object(oid);
if (!o) {
return seastar::make_exception_future<ceph::bufferptr>(
EnoentException(fmt::format("object does not exist: {}", oid)));
}
if (auto found = o->xattr.find(name); found != o->xattr.end()) {
return seastar::make_ready_future<ceph::bufferptr>(found->second);
} else {
return seastar::make_exception_future<ceph::bufferptr>(
EnodataException(fmt::format("attr does not exist: {}/{}", oid,
name)));
}
}
What are the errors here?
10
Is get_object() anyhow relevant from the perspective of error handling?
What are the errors here?
11
Is get_object() anyhow relevant from the perspective of error handling?
Actually no:
What are the errors here?
Collection::ObjectRef Collection::get_object(ghobject_t oid)
{
auto o = object_hash.find(oid);
if (o == object_hash.end())
return ObjectRef();
return o->second;
}
12
Summary
Not all errors happen exceptionally.
Straight exceptions are not the best tool in such
situation.
13
errorator<> errorates
future<> at compile-time
14
Goals
● Performance – no throw/catch neither on signaling nor
inspecting.
● Type safety – ensure proper error handling. Ignoring
errors is fine till you do it explicitly.
● Improve code readability – make errors part of signature.
● No revolution. Keep changes minimal and separated.
15
● Header-only library separated from Seastar
● Java's checked exceptions for Seastar built on top of:
○ the Gleb's improvement for std::make_exception_ptr(),
○ __cxa_exception_type().
● 700 lines of hard-to-understand C++ metaprogramming
● Class template nesting derivative of seastar::future.
What errorator is?
16
template <class... AllowedErrors>
struct errorator {
// …
template <class... ValuesT>
class future<ValuesT...>
: private seastar::future<ValuesT...> {
// NO ADDITIONAL DATA.
// sizeof(errorated future) == sizeof(seastar::future)
};
};
ceph::errorator<> literally
17
Empty errorator aliases seastar::future.
template <>
class errorator<> {
public:
template <class... ValuesT>
using future = ::seastar::future<ValuesT...>;
};
ceph::errorator<> literally
18
Composing an errorator resembles defining enum.
using get_attr_errorator = ceph::errorator<
ceph::ct_error::enoent,
ceph::ct_error::enodata>;
These errors are aliases to instances of std::error_code
wrapped with unthrowable wrapper to prevent accidental
throwing.
Usage
19
CyanStore::get_attr_errorator::future<ceph::bufferptr>
CyanStore::get_attr(
/* ... */) const
{
// ...
throw ceph::ct_error::enoent; // won’t compile
throw ceph::ct_error::enoent::make(); // won’t compile
return ceph::ct_error::enoent::make();
}
Usage
20
● Is not implicitly convertible into seastar::future.
● Its interface offers safe_then() and basically nothing else.
● safe_then() is like then() apart:
○ can take error handlers,
○ returns potentially differently errorated future depending on the result of error handling.
● Handling an error squeezes it from return errorator's error set but
● signaling new error anywhere inside safe_then() appends it to the set,
The errorated future
21
seastar::future<PGBackend::cached_os_t > // == ceph::errorator<>::future<...>
PGBackend::_load_os(const hobject_t& oid)
return store->get_attr(coll,
ghobject_t{oid, ghobject_t::NO_GEN, shard},
OI_ATTR)
.safe_then(
[] (ceph::bufferptr&& bp) {
// optimistic path
}, ceph::errorator< ceph::ct_error::enoent,
ceph::ct_error::enodata>::all_same_way([oid, this] {
return seastar::make_ready_future<cached_os_t>(
os_cache.insert(oid,
std::make_unique<ObjectState>(object_info_t{oid}, false)));
}));
Usage
22
seastar::future<PGBackend::cached_os_t > // won’t compile
PGBackend::_load_os(const hobject_t& oid)
return store->get_attr(coll,
ghobject_t{oid, ghobject_t::NO_GEN, shard},
OI_ATTR)
.safe_then(
[] (ceph::bufferptr&& bp) {
// optimistic path
}, ceph::ct_error::enoent::handle([oid, this] {
return seastar::make_ready_future <cached_os_t>(
os_cache.insert(oid,
std::make_unique<ObjectState>(object_info_t{oid}, false)));
}));
Usage – chaining
23
ceph::errorator<ceph::ct_error::enodata>::future<PGBackend::cached_os_t >
PGBackend::_load_os(const hobject_t& oid)
return store->get_attr(coll,
ghobject_t{oid, ghobject_t::NO_GEN, shard},
OI_ATTR)
.safe_then(
[] (ceph::bufferptr&& bp) {
// optimistic path
}, ceph::ct_error::enoent::handle([oid, this] {
return seastar::make_ready_future <cached_os_t>(
os_cache.insert(oid,
std::make_unique<ObjectState>(object_info_t{oid}, false)));
}));
Usage – chaining
24
Limitations,
problems,
plans
25
__cxa_exception_data()?
● Only type can be inspected in the throw-free way.
This is fine for stateless objects.
● Currently there is no __cxa_exception_data() to cover
stateful errors.
● It might be feasible to get this feature as compiler’s
extension.
26
● then_wrapped()-imposed temporary future creation,
● get() instead get_available_state() brings some
garbage.
● Converting differently errorated futures imposes move.
Performance
27
● safe_then() is implemented with then_wrapped().
It provides the passed callable with a copy of the future
instead of *this.
● Getting rid of that is an opportunity for generic
optimization.
● Another possibility is to stop using then_wrapped() but
access to private members would be necessary.
More copying because of then_wrapped()
28
No access to get_available_state()
● safe_then() retrieves the value with the less efficient get() which checks
and does blocking for seastar::thread. DCE doesn’t optimize this out.
// if (__builtin_expect(future.failed(), false)) {
// ea25: 48 83 bd c8 fe ff ff cmpq $0x2,-0x138(%rbp)
// ea2c: 02
// ea2d: 0f 87 f0 05 00 00 ja f023 <ceph::osd::
// ...
// /// If get() is called in a ref seastar::thread context,
// /// then it need not be available; instead, the thread will
// /// be paused until the future becomes available.
// [[gnu::always_inline]]
// std::tuple<T...> get() {
// if (!_state.available()) {
// ea3a: 0f 85 1b 05 00 00 jne ef5b <ceph::osd::
// }
29
--- a/include/seastar/core/future.hh
+++ b/include/seastar/core/future.hh
@@ -729,7 +729,7 @@ class future {
promise<T...>* _promise;
future_state<T...> _state;
static constexpr bool copy_noexcept = future_state<T...>::copy_noexcept;
-private:
+protected:
future(promise<T...>* pr) noexcept : _promise(pr),
_state(std::move(pr->_local_state)) {
_promise->_future = this;
_promise->_state = &_state;
protected instead of private?
30
Converting differently errorated futures requires moving.
PGBackend::stat_errorator::future<> PGBackend::stat(
const ObjectState& os,
OSDOp& osd_op)
{
// …
- return seastar::now();
+ return stat_errorator::now();
}
Extra moves
31
● Errorator future is not a future from the perspective of e.g.
seastar::do_for_each().
● Rewriting future-util.hh would be painful and rudimentary
● There is already the concept of seastar::is_future<> trait but not all of
the utilities make use of it.
seastar::is_future<>
template<typename Iterator, typename AsyncAction>
GCC6_CONCEPT( requires requires (Iterator i, AsyncAction aa) {
{ futurize_apply(aa, *i) } -> future<>;
} )
inline
future<> do_for_each(Iterator begin, Iterator end, AsyncAction action) {
32
● Optimizing errorator unveiled unnecessary temporary spawning on hot paths:
○ future::get_available_state(),
○ future::get(),
○ future_state::get().
● There is release candidate of patchset optimizing them out:
https://github.com/ceph/seastar/pull/9
The unnecessary temporaries
33
?
Q&A
The pull request with errorator:
https://github.com/ceph/ceph/pull/30387
34
● https://ceph.io/
● Twitter: @ceph
● Docs: http://docs.ceph.com/
● Mailing lists: http://lists.ceph.io/
○ ceph-announce@ceph.io → announcements
○ ceph-users@ceph.io → user discussion
○ dev@ceph.io → developer discussion
● IRC: irc.oftc.net
○ #ceph, #ceph-devel
● GitHub: https://github.com/ceph/
● YouTube ‘Ceph’ channel
FOR MORE INFORMATION

Mais conteúdo relacionado

Mais procurados

The Unicorn Getting Interested in KDE
The Unicorn Getting Interested in KDEThe Unicorn Getting Interested in KDE
The Unicorn Getting Interested in KDEAndrey Karpov
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Igalia
 
Openstack taskflow 簡介
Openstack taskflow 簡介Openstack taskflow 簡介
Openstack taskflow 簡介kao kuo-tung
 
How to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinSigma Software
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? ICS
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUJohn Colvin
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixCodemotion Tel Aviv
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineNarann29
 
To Swift 2...and Beyond!
To Swift 2...and Beyond!To Swift 2...and Beyond!
To Swift 2...and Beyond!Scott Gardner
 
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeksBeginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeksJinTaek Seo
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)Igalia
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt CommunicationAndreas Jakl
 
CUDA Tutorial 01 : Say Hello to CUDA : Notes
CUDA Tutorial 01 : Say Hello to CUDA : NotesCUDA Tutorial 01 : Say Hello to CUDA : Notes
CUDA Tutorial 01 : Say Hello to CUDA : NotesSubhajit Sahu
 
Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7Pasi Kellokoski
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the wayOleg Podsechin
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The LandingHaci Murat Yaman
 

Mais procurados (20)

Openstack 簡介
Openstack 簡介Openstack 簡介
Openstack 簡介
 
The Unicorn Getting Interested in KDE
The Unicorn Getting Interested in KDEThe Unicorn Getting Interested in KDE
The Unicorn Getting Interested in KDE
 
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
Good news, everybody! Guile 2.2 performance notes (FOSDEM 2016)
 
Openstack taskflow 簡介
Openstack taskflow 簡介Openstack taskflow 簡介
Openstack taskflow 簡介
 
How to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita GalkinHow to make a high-quality Node.js app, Nikita Galkin
How to make a high-quality Node.js app, Nikita Galkin
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
 
clWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPUclWrap: Nonsense free control of your GPU
clWrap: Nonsense free control of your GPU
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, Wix
 
C++ Coroutines
C++ CoroutinesC++ Coroutines
C++ Coroutines
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering Pipeline
 
To Swift 2...and Beyond!
To Swift 2...and Beyond!To Swift 2...and Beyond!
To Swift 2...and Beyond!
 
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeksBeginning direct3d gameprogrammingcpp02_20160324_jintaeks
Beginning direct3d gameprogrammingcpp02_20160324_jintaeks
 
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
function* - ES6, generators, and all that (JSRomandie meetup, February 2014)
 
Grover's Algorithm
Grover's AlgorithmGrover's Algorithm
Grover's Algorithm
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt Communication
 
04 - Qt Data
04 - Qt Data04 - Qt Data
04 - Qt Data
 
CUDA Tutorial 01 : Say Hello to CUDA : Notes
CUDA Tutorial 01 : Say Hello to CUDA : NotesCUDA Tutorial 01 : Say Hello to CUDA : Notes
CUDA Tutorial 01 : Say Hello to CUDA : Notes
 
Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
Node.js System: The Landing
Node.js System: The LandingNode.js System: The Landing
Node.js System: The Landing
 

Semelhante a ceph::errorator<> throw/catch-free, compile time-checked exceptions for seastar::future<>

C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...corehard_by
 
Checking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xChecking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xAndrey Karpov
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumlercorehard_by
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeMicrosoft Tech Community
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2PVS-Studio
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgePVS-Studio
 
C++ exception handling
C++ exception handlingC++ exception handling
C++ exception handlingRay Song
 
Other Approaches (Concurrency)
Other Approaches (Concurrency)Other Approaches (Concurrency)
Other Approaches (Concurrency)Sri Prasanna
 
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...Kamiya Toshihiro
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...Doug Jones
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linuxMiller Lee
 
CUDA Deep Dive
CUDA Deep DiveCUDA Deep Dive
CUDA Deep Divekrasul
 
6-Exception Handling and Templates.pptx
6-Exception Handling and Templates.pptx6-Exception Handling and Templates.pptx
6-Exception Handling and Templates.pptxSatyamMishra237306
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsPVS-Studio
 
How Does Kubernetes Build OpenAPI Specifications?
How Does Kubernetes Build OpenAPI Specifications?How Does Kubernetes Build OpenAPI Specifications?
How Does Kubernetes Build OpenAPI Specifications?reallavalamp
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPMiller Lee
 

Semelhante a ceph::errorator<> throw/catch-free, compile time-checked exceptions for seastar::future<> (20)

C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
C++ CoreHard Autumn 2018. Concurrency and Parallelism in C++17 and C++20/23 -...
 
Checking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-xChecking the Cross-Platform Framework Cocos2d-x
Checking the Cross-Platform Framework Cocos2d-x
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumler
 
Modern c++
Modern c++Modern c++
Modern c++
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
How to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ CodeHow to Adopt Modern C++17 into Your C++ Code
How to Adopt Modern C++17 into Your C++ Code
 
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
Analysis of Haiku Operating System (BeOS Family) by PVS-Studio. Part 2
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
 
C++ exception handling
C++ exception handlingC++ exception handling
C++ exception handling
 
Other Approaches (Concurrency)
Other Approaches (Concurrency)Other Approaches (Concurrency)
Other Approaches (Concurrency)
 
Scala to assembly
Scala to assemblyScala to assembly
Scala to assembly
 
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...
 
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
JavaScript: The Good Parts Or: How A C# Developer Learned To Stop Worrying An...
 
Performance measurement and tuning
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
 
C++ amp on linux
C++ amp on linuxC++ amp on linux
C++ amp on linux
 
CUDA Deep Dive
CUDA Deep DiveCUDA Deep Dive
CUDA Deep Dive
 
6-Exception Handling and Templates.pptx
6-Exception Handling and Templates.pptx6-Exception Handling and Templates.pptx
6-Exception Handling and Templates.pptx
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code Contracts
 
How Does Kubernetes Build OpenAPI Specifications?
How Does Kubernetes Build OpenAPI Specifications?How Does Kubernetes Build OpenAPI Specifications?
How Does Kubernetes Build OpenAPI Specifications?
 
GPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMPGPU Programming on CPU - Using C++AMP
GPU Programming on CPU - Using C++AMP
 

Mais de ScyllaDB

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
What Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQLWhat Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQLScyllaDB
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsScyllaDB
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasScyllaDB
 
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBBeyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBScyllaDB
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasScyllaDB
 
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...ScyllaDB
 
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...ScyllaDB
 
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr SarnaDatabase Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr SarnaScyllaDB
 
Replacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBScyllaDB
 
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear ScalabilityPowering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear ScalabilityScyllaDB
 
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptxScyllaDB
 
Getting the most out of ScyllaDB
Getting the most out of ScyllaDBGetting the most out of ScyllaDB
Getting the most out of ScyllaDBScyllaDB
 
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a MigrationNoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a MigrationScyllaDB
 
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsNoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsScyllaDB
 
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and ChallengesNoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and ChallengesScyllaDB
 
ScyllaDB Virtual Workshop
ScyllaDB Virtual WorkshopScyllaDB Virtual Workshop
ScyllaDB Virtual WorkshopScyllaDB
 
DBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & TradeoffsDBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & TradeoffsScyllaDB
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBScyllaDB
 
NoSQL Data Modeling 101
NoSQL Data Modeling 101NoSQL Data Modeling 101
NoSQL Data Modeling 101ScyllaDB
 

Mais de ScyllaDB (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
What Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQLWhat Developers Need to Unlearn for High Performance NoSQL
What Developers Need to Unlearn for High Performance NoSQL
 
Low Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & PitfallsLow Latency at Extreme Scale: Proven Practices & Pitfalls
Low Latency at Extreme Scale: Proven Practices & Pitfalls
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance Dilemmas
 
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDBBeyond Linear Scaling: A New Path for Performance with ScyllaDB
Beyond Linear Scaling: A New Path for Performance with ScyllaDB
 
Dissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance DilemmasDissecting Real-World Database Performance Dilemmas
Dissecting Real-World Database Performance Dilemmas
 
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
Database Performance at Scale Masterclass: Workload Characteristics by Felipe...
 
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
Database Performance at Scale Masterclass: Database Internals by Pavel Emelya...
 
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr SarnaDatabase Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
Database Performance at Scale Masterclass: Driver Strategies by Piotr Sarna
 
Replacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDBReplacing Your Cache with ScyllaDB
Replacing Your Cache with ScyllaDB
 
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear ScalabilityPowering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
Powering Real-Time Apps with ScyllaDB_ Low Latency & Linear Scalability
 
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx7 Reasons Not to Put an External Cache in Front of Your Database.pptx
7 Reasons Not to Put an External Cache in Front of Your Database.pptx
 
Getting the most out of ScyllaDB
Getting the most out of ScyllaDBGetting the most out of ScyllaDB
Getting the most out of ScyllaDB
 
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a MigrationNoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
NoSQL Database Migration Masterclass - Session 2: The Anatomy of a Migration
 
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration LogisticsNoSQL Database Migration Masterclass - Session 3: Migration Logistics
NoSQL Database Migration Masterclass - Session 3: Migration Logistics
 
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and ChallengesNoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
NoSQL Data Migration Masterclass - Session 1 Migration Strategies and Challenges
 
ScyllaDB Virtual Workshop
ScyllaDB Virtual WorkshopScyllaDB Virtual Workshop
ScyllaDB Virtual Workshop
 
DBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & TradeoffsDBaaS in the Real World: Risks, Rewards & Tradeoffs
DBaaS in the Real World: Risks, Rewards & Tradeoffs
 
Build Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDBBuild Low-Latency Applications in Rust on ScyllaDB
Build Low-Latency Applications in Rust on ScyllaDB
 
NoSQL Data Modeling 101
NoSQL Data Modeling 101NoSQL Data Modeling 101
NoSQL Data Modeling 101
 

Último

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Último (20)

unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

ceph::errorator<> throw/catch-free, compile time-checked exceptions for seastar::future<>

  • 1. 1 ceph::errorator<> throw/catch-free, compile time-checked exceptions for seastar::future<> Radosław Zarzyński Seastar Summit 2019 2019.11.04
  • 2. 2 Error handling with seastar::future ● future_state_base is discriminated union between promised value and std::exception_ptr. ● Signaling: ○ throw Exception() or ○ seastar::make_exception_future<T…>(Exception&& ex) or ○ Its second variant taking std::exception_ptr. ● Inspecting: ○ handle_exception_type<ExceptionTakingFunc>(...) or ○ handle_exception(...) and raw std::exception_ptr.
  • 3. 3 ● Throwing on current implementation imposes costs both in the terms of ○ performance (computational resources) and ○ scalability (number of threads throwing the same time). ● The scalability limitations have been only partially tackled down in GCC. Throwing still imposes locking. ● Seastar workarounds the issue with the exception scalability hack at the price of assuming no dlopen() after the initialization phase. ● The hack should be disabled in crimson as loading plugins is necessary to fully mimic the interfaces of current OSD’s interfaces. What’s wrong with throwing?
  • 4. 4 ● Zero-cost exceptions tend to be slow when it comes to throwing... ● … but without the exception hack they are also not scalable. ● The make_exception_future path on GCC is throw-free after Gleb Natapov's optimization for std::make_exception_ptr implementation in libstdc++. ● Programmer is not enforced to use the optimized path – someone still can throw. ● Is there better way than review? Signaling try { - throw __ex; +#if __cpp_rtti && !_GLIBCXX_HAVE_CDTOR_CALLABI + void *__e = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ex)); + (void)__cxxabiv1::__cxa_init_primary_exception(__e, + const_cast<std::type_info*>(&typeid(__ex)), + __exception_ptr::__dest_thunk<_Ex>); + new (__e) _Ex(__ex); + return exception_ptr(__e); +#else + throw __ex; +#endif } catch(...)
  • 5. 5 ● handle_exception_type() is not suitable for a hot path due to rethrowing ● handle_exception() doesn’t solve the problem of differentiating behavior basing on exception type; it just delegates it outside. ● Is there a throw-free approach to match ExceptionA but not ExceptionB? std::tuple<T...> get() const& { // … if (_u.st >= state::exception_min) std::rethrow_exception(_u.ex); // ... } template <typename Func> future<T...> handle_exception_type(Func&& func) noexcept { // ... return then_wrapped([func = std::forward<Func>(func)] (auto&& fut) mutable -> future<T...> { try { return make_ready_future<T...>(fut.get()); } catch(ex_type& ex) { return futurize<func_ret>::apply(func, ex); } Inspecting
  • 6. 6 ● Allows for fast, throw-free type inspection of std::exception_ptr: *ep.__cxa_exception_type() == typeid(ExceptionA); ● Compiler extension present in both GCC and Clang. ● For other compilers can be mimicked on top of try/catch. __cxa_exception_type() class exception_ptr { const std::type_info* __cxa_exception_type() const; }
  • 7. 7 ● The expression does exact matching while it’s perfectly fine to: fut.handle_exception_type([] (ExceptionBase&) {}); ● So maybe handle_exception_exact_type()? Drop-in replacement for handle_exception_type?
  • 8. 8 seastar::future<ceph::bufferptr> CyanStore::get_attr( CollectionRef ch, const ghobject_t& oid, std::string_view name) const; What are the errors here? ● What will happen if object does not exist? ● How no-object is distinguished from no-key?
  • 9. 9 seastar::future<ceph::bufferptr> CyanStore::get_attr( // … { auto o = c->get_object(oid); if (!o) { return seastar::make_exception_future<ceph::bufferptr>( EnoentException(fmt::format("object does not exist: {}", oid))); } if (auto found = o->xattr.find(name); found != o->xattr.end()) { return seastar::make_ready_future<ceph::bufferptr>(found->second); } else { return seastar::make_exception_future<ceph::bufferptr>( EnodataException(fmt::format("attr does not exist: {}/{}", oid, name))); } } What are the errors here?
  • 10. 10 Is get_object() anyhow relevant from the perspective of error handling? What are the errors here?
  • 11. 11 Is get_object() anyhow relevant from the perspective of error handling? Actually no: What are the errors here? Collection::ObjectRef Collection::get_object(ghobject_t oid) { auto o = object_hash.find(oid); if (o == object_hash.end()) return ObjectRef(); return o->second; }
  • 12. 12 Summary Not all errors happen exceptionally. Straight exceptions are not the best tool in such situation.
  • 14. 14 Goals ● Performance – no throw/catch neither on signaling nor inspecting. ● Type safety – ensure proper error handling. Ignoring errors is fine till you do it explicitly. ● Improve code readability – make errors part of signature. ● No revolution. Keep changes minimal and separated.
  • 15. 15 ● Header-only library separated from Seastar ● Java's checked exceptions for Seastar built on top of: ○ the Gleb's improvement for std::make_exception_ptr(), ○ __cxa_exception_type(). ● 700 lines of hard-to-understand C++ metaprogramming ● Class template nesting derivative of seastar::future. What errorator is?
  • 16. 16 template <class... AllowedErrors> struct errorator { // … template <class... ValuesT> class future<ValuesT...> : private seastar::future<ValuesT...> { // NO ADDITIONAL DATA. // sizeof(errorated future) == sizeof(seastar::future) }; }; ceph::errorator<> literally
  • 17. 17 Empty errorator aliases seastar::future. template <> class errorator<> { public: template <class... ValuesT> using future = ::seastar::future<ValuesT...>; }; ceph::errorator<> literally
  • 18. 18 Composing an errorator resembles defining enum. using get_attr_errorator = ceph::errorator< ceph::ct_error::enoent, ceph::ct_error::enodata>; These errors are aliases to instances of std::error_code wrapped with unthrowable wrapper to prevent accidental throwing. Usage
  • 19. 19 CyanStore::get_attr_errorator::future<ceph::bufferptr> CyanStore::get_attr( /* ... */) const { // ... throw ceph::ct_error::enoent; // won’t compile throw ceph::ct_error::enoent::make(); // won’t compile return ceph::ct_error::enoent::make(); } Usage
  • 20. 20 ● Is not implicitly convertible into seastar::future. ● Its interface offers safe_then() and basically nothing else. ● safe_then() is like then() apart: ○ can take error handlers, ○ returns potentially differently errorated future depending on the result of error handling. ● Handling an error squeezes it from return errorator's error set but ● signaling new error anywhere inside safe_then() appends it to the set, The errorated future
  • 21. 21 seastar::future<PGBackend::cached_os_t > // == ceph::errorator<>::future<...> PGBackend::_load_os(const hobject_t& oid) return store->get_attr(coll, ghobject_t{oid, ghobject_t::NO_GEN, shard}, OI_ATTR) .safe_then( [] (ceph::bufferptr&& bp) { // optimistic path }, ceph::errorator< ceph::ct_error::enoent, ceph::ct_error::enodata>::all_same_way([oid, this] { return seastar::make_ready_future<cached_os_t>( os_cache.insert(oid, std::make_unique<ObjectState>(object_info_t{oid}, false))); })); Usage
  • 22. 22 seastar::future<PGBackend::cached_os_t > // won’t compile PGBackend::_load_os(const hobject_t& oid) return store->get_attr(coll, ghobject_t{oid, ghobject_t::NO_GEN, shard}, OI_ATTR) .safe_then( [] (ceph::bufferptr&& bp) { // optimistic path }, ceph::ct_error::enoent::handle([oid, this] { return seastar::make_ready_future <cached_os_t>( os_cache.insert(oid, std::make_unique<ObjectState>(object_info_t{oid}, false))); })); Usage – chaining
  • 23. 23 ceph::errorator<ceph::ct_error::enodata>::future<PGBackend::cached_os_t > PGBackend::_load_os(const hobject_t& oid) return store->get_attr(coll, ghobject_t{oid, ghobject_t::NO_GEN, shard}, OI_ATTR) .safe_then( [] (ceph::bufferptr&& bp) { // optimistic path }, ceph::ct_error::enoent::handle([oid, this] { return seastar::make_ready_future <cached_os_t>( os_cache.insert(oid, std::make_unique<ObjectState>(object_info_t{oid}, false))); })); Usage – chaining
  • 25. 25 __cxa_exception_data()? ● Only type can be inspected in the throw-free way. This is fine for stateless objects. ● Currently there is no __cxa_exception_data() to cover stateful errors. ● It might be feasible to get this feature as compiler’s extension.
  • 26. 26 ● then_wrapped()-imposed temporary future creation, ● get() instead get_available_state() brings some garbage. ● Converting differently errorated futures imposes move. Performance
  • 27. 27 ● safe_then() is implemented with then_wrapped(). It provides the passed callable with a copy of the future instead of *this. ● Getting rid of that is an opportunity for generic optimization. ● Another possibility is to stop using then_wrapped() but access to private members would be necessary. More copying because of then_wrapped()
  • 28. 28 No access to get_available_state() ● safe_then() retrieves the value with the less efficient get() which checks and does blocking for seastar::thread. DCE doesn’t optimize this out. // if (__builtin_expect(future.failed(), false)) { // ea25: 48 83 bd c8 fe ff ff cmpq $0x2,-0x138(%rbp) // ea2c: 02 // ea2d: 0f 87 f0 05 00 00 ja f023 <ceph::osd:: // ... // /// If get() is called in a ref seastar::thread context, // /// then it need not be available; instead, the thread will // /// be paused until the future becomes available. // [[gnu::always_inline]] // std::tuple<T...> get() { // if (!_state.available()) { // ea3a: 0f 85 1b 05 00 00 jne ef5b <ceph::osd:: // }
  • 29. 29 --- a/include/seastar/core/future.hh +++ b/include/seastar/core/future.hh @@ -729,7 +729,7 @@ class future { promise<T...>* _promise; future_state<T...> _state; static constexpr bool copy_noexcept = future_state<T...>::copy_noexcept; -private: +protected: future(promise<T...>* pr) noexcept : _promise(pr), _state(std::move(pr->_local_state)) { _promise->_future = this; _promise->_state = &_state; protected instead of private?
  • 30. 30 Converting differently errorated futures requires moving. PGBackend::stat_errorator::future<> PGBackend::stat( const ObjectState& os, OSDOp& osd_op) { // … - return seastar::now(); + return stat_errorator::now(); } Extra moves
  • 31. 31 ● Errorator future is not a future from the perspective of e.g. seastar::do_for_each(). ● Rewriting future-util.hh would be painful and rudimentary ● There is already the concept of seastar::is_future<> trait but not all of the utilities make use of it. seastar::is_future<> template<typename Iterator, typename AsyncAction> GCC6_CONCEPT( requires requires (Iterator i, AsyncAction aa) { { futurize_apply(aa, *i) } -> future<>; } ) inline future<> do_for_each(Iterator begin, Iterator end, AsyncAction action) {
  • 32. 32 ● Optimizing errorator unveiled unnecessary temporary spawning on hot paths: ○ future::get_available_state(), ○ future::get(), ○ future_state::get(). ● There is release candidate of patchset optimizing them out: https://github.com/ceph/seastar/pull/9 The unnecessary temporaries
  • 33. 33 ? Q&A The pull request with errorator: https://github.com/ceph/ceph/pull/30387
  • 34. 34 ● https://ceph.io/ ● Twitter: @ceph ● Docs: http://docs.ceph.com/ ● Mailing lists: http://lists.ceph.io/ ○ ceph-announce@ceph.io → announcements ○ ceph-users@ceph.io → user discussion ○ dev@ceph.io → developer discussion ● IRC: irc.oftc.net ○ #ceph, #ceph-devel ● GitHub: https://github.com/ceph/ ● YouTube ‘Ceph’ channel FOR MORE INFORMATION