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

Improve backend performance #284

Closed
Superjomn opened this issue Feb 28, 2018 · 1 comment
Closed

Improve backend performance #284

Superjomn opened this issue Feb 28, 2018 · 1 comment
Assignees

Comments

@Superjomn
Copy link
Contributor

Currently, some implementation of the backend is naive, work not slow. For that, the user will embed backend SDK into their training phase, and the backend will be triggered frequently, so the logger's performance is crucial.

A rough look at the details, there are several modules should be tuned, I list them based on the importance order:

  1. storage/Storage::PersistToDisk, this method will save all the tablets from memory into disk even if some of them are not changed at all.
  2. WRITE_GUARD, it is a trick to use a counter and mod some frequency to avoid the need for concurrency. But the write operation takes overhead, it better to use an async operation instead.
  3. Adding record is expensive, for example, Image 's record adding needs to rescale all the pixels, such operations should change to asnyc.

All in all, there are two aspects to improve. First, the PersistToDist should ignore the tablets that havn't changed; second, some expensive operations should change to async ones.

The first issue is quite intuitive; let's focus on the second one.

For async tasks, thread queue is a good choice, but not suitable for this task. The operations on tablets have some dependencies which are hard to describe by stateless threads, and it is painful to introduce more condition variable or mutex. Dependency engine is a good choice, it handles dependencies naturally, and support concurrency programming without the need for condition variable or mutex.

dependency engine as a concurrent programming framework

VisualDL might be used in a parallel system, that is the SDK might be called parallelly. The dependency engine is similar to a task queue; the tasks can be added parallelly with a single mutex to protect the internal states.

The tasks can be executed parallelly by a thread pool. Both the state control and thread pool are hidden in the dependency engine, the change to VisualDL is just the task pushing logic.

For example, the heavy Image::SetSample can embed into a task and accelerated by the underlying thread-pool.

performance stats

We can reference CPU prof to get some details of the backend performance.

@ZeyuChen
Copy link
Member

VisualDL 2.0 use stream down sampling method to solve backend perf issues now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants