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

Implement new Cairo + RSVG SVG backend [DISCL-379] #69

Merged
merged 1 commit into from
Jul 27, 2016

Conversation

rdumusc
Copy link

@rdumusc rdumusc commented Jul 26, 2016

No description provided.


mutable QMutex _threadMapMutex;
typedef std::unique_ptr<SVG> SVGPtr;
mutable std::map<Qt::HANDLE, SVGPtr> _perThreadSVG;
Copy link
Contributor

@tribal-tec tribal-tec Jul 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use boost::thread_specific_ptr or QThreadStorage for per-thread objects

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting point, but there is a catch here. Apparently QThreadStorage destructor does not deallocate objects, they are instead deleted when the thread that created them exits. Since the calling threads are from the global QThreadPool, in our case the resources would be "leaked" until the application exits. boost::thread_specific_ptr has the same behaviour, and is meant to be used with boost::thread instead of QThread. The reason invoked for this is that it may not be safe to deallocate objects allocated by a different thread. I am not sure if this may be a concern in this case, I copied this implementation from the PDFTiler where we were doing the same.

In any case this multi-threading is quite problematic because allocating a new RSVG context for a ~80MB file takes in the order of ~5s, but then subsequent render calls are faster because they are fully parallel. Using a single RSVG context, the initial impact is lower, but then the render call have to be serialized because RSVG is not thread-safe, which can even slow down the entire QThreadPool. I am not sure what is the optimal solution here.

@rdumusc rdumusc merged commit cf09875 into BlueBrain:master Jul 27, 2016
@rdumusc rdumusc deleted the svg branch July 27, 2016 15:42
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.

2 participants