Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove altogether the Vector cache for MVPosition and Euler classes. #716

Merged
merged 1 commit into from
Jun 7, 2018

Conversation

cquike
Copy link
Contributor

@cquike cquike commented Mar 27, 2018

This PR removes altogether the Vector cache for MVPosition and Euler classes that was introduced
in #258 and modified in #680.
The cache was implemented using a thread_local storage, which means that the cache shouldn't be shared among different threads. This was unfortunately the case, since the MeasTable class creates some global objects that include instances of MVPosition derived classes. This causes
undefined behaviours, since the constructors for thread_local variables are called before the destructors for the global variables, according to the C++11 standard. Running the tTableMeasures test triggered in fact a segmentation fault due to this and valgrind reports those errors.

The original cache implementation didn't clean the memory, so the problem was simply hidden. The original idea of the cache was to improve the performance, achieving around 5x boost when objects are constantly being allocated and deleted. However, in a quick test I replaced Vector with std::array<double,3> (C++11) and I got a ~70x performance boost without any extra cache, so that might be a better route to explore, rather than a cache that is difficult to get it right.

It was implemented using a thread_local storage, which means that
the cache shouldn't be shared among different threads. This was
unfortunely the case, since the MeasTable class creates some global
objects that include instances of MVPosition derived classes. This causes
undefined behaviours, since the constructors for thread_local variables are
called before the destructors for the global variables, according
to the C++11 standard. Running the tTableMeasures test triggered in fact
a segmentation fault due to this.

The original cache implementation didn't clean the memory, so the
problem was simply hidden. The original idea of the cache is
improve the performance, achieving around 5x boost when many objects
are allocated and deleted. However, in a quick test I replaced
Vector<Double> with std::array<double,3> (C++11) and I got a ~70x performance
boost without any extra cache, so that might be a better route.

Fixes CAS-10326
@tammojan
Copy link
Contributor

tammojan commented Jun 7, 2018

Thanks. Looks fine with me (and apparently no one objects). Note that by now we can assume having C++11 available (see #580), which should pave the path for better optimizations.

@tammojan tammojan merged commit a87e93a into casacore:master Jun 7, 2018
@gijzelaerr gijzelaerr added this to the 2.5 milestone Oct 31, 2018
@cquike cquike deleted the remove_quanta_cache branch February 18, 2019 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants