[Development] QVariant performance

Sean Harmer sean.harmer at kdab.com
Mon May 16 12:52:57 CEST 2016


On Monday 16 May 2016 12:32:41 Mark Gaiser wrote:
> Hi,
> 
> Just a fyi since the article might be of interest to some on this list.
> I just stumbled upon this github project [1].
> The article and rationale for that project can be found here [2].
> 
> It claims to be a stack based "variant" implementation made for performance
> and as little overhead as possible. Perhaps the code has some nice tricks
> that could be used to make QVariant faster? QVariant in those benchmarks,
> as seen in [1], seems to be the slowest when compared to std::any,
> boost::any and his own variant.

Thanks for the article.

QVariant has to deal with dynamic type registration. This in turn leads to 
lots of locking of metatype information - something that profiling Qt 3D has 
pointed as being an issue.

In the case of the article you link and for Qt 3D we have a set of known types 
that we need to cater for. So QVariant is too general here and some templated 
types will be better suited and higher performing than QVariant or any other 
variant like type.

We have a WIP to replace the use of QVariant on the backend of Qt 3D but it 
would benefit all of Qt (including Qt 3D frontend to backend change 
notifications) if we can also improve the locking behaviour of QVariant. We 
have some ideas here to either use thread local storage in addition to the 
global metatype information registry and/or to use a scheme involving atomic 
compare/exchange when updating metatype registration info.

Cheers,

Sean

> 
> [1] https://github.com/david-grs/static_any
> [2] http://david-grs.github.io/low_latency_stack_based_boost_any/

--
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. UK +44 (0)1625 809908, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions



More information about the Development mailing list