Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2729)

Issue 6755043: Figuring out how to integrate this threadpool into Skia.

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 6 months ago by mtklein
Modified:
11 years, 6 months ago
Reviewers:
Leon
CC:
skia-review_googlegroups.com
Base URL:
http://skia.googlecode.com/svn/trunk
Visibility:
Public.

Description

I wrote up a thread pool blindly ignorant of the Skia codebase (here under threads/) and am now trying to figure out how to express it in Skia. I have some guesses but I think it'd be helpful to get early feedback: - Instead of vector<T> I should be using SkTArray<T> or SkTDArray<T>. - Instead of queue<T> I should be using SkLinkedList<T>. - Where I write CondVar I suspect I want to abstract out PthreadEvent/HANDLE into a platform-dependent SkCondVar class. - Seems like we use pthreads everywhere but Windows, which is terra incognita to me. I haven't even looked at Windows yet, but the instructions on skiadocs look doable. - I think I want to move Runnable and ThreadPool into SkThreadUtils. Does it seem like I'm on the right track? I've also added in a small tweak and script I've been using to see how the pictures benchmarks varies when run with various numbers of threads.

Patch Set 1 #

Patch Set 2 : forgot geomean #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+303 lines, -3 lines) Patch
A bench.sh View 1 1 chunk +4 lines, -0 lines 0 comments Download
A geomean View 1 1 chunk +13 lines, -0 lines 0 comments Download
A threads/Tupfile View 1 chunk +4 lines, -0 lines 0 comments Download
A threads/bench.sh View 1 chunk +19 lines, -0 lines 0 comments Download
A threads/condvar.h View 1 chunk +21 lines, -0 lines 0 comments Download
A threads/condvar.cc View 1 chunk +27 lines, -0 lines 0 comments Download
A threads/countdown.h View 1 chunk +18 lines, -0 lines 0 comments Download
A threads/countdown.cc View 1 chunk +18 lines, -0 lines 2 comments Download
A threads/main.cc View 1 chunk +59 lines, -0 lines 0 comments Download
A threads/runnable.h View 1 chunk +6 lines, -0 lines 0 comments Download
A threads/threadpool.h View 1 chunk +32 lines, -0 lines 1 comment Download
A threads/threadpool.cc View 1 chunk +79 lines, -0 lines 0 comments Download
M tools/bench_pictures_main.cpp View 2 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 5
mtklein
Hiya. Can you help me integrating this into Skia? It's a rather different codebase than ...
11 years, 6 months ago (2012-10-23 18:39:32 UTC) #1
Leon
Looks like the right track to me. It seems you left out PictureRenderer? I'm curious ...
11 years, 6 months ago (2012-10-23 19:58:51 UTC) #2
mtklein
On 2012/10/23 19:58:51, scroggo-work wrote: > Looks like the right track to me. It seems ...
11 years, 6 months ago (2012-10-23 20:17:27 UTC) #3
Leon
> Looking at main.cc, it looks to me like you >> require the client to ...
11 years, 6 months ago (2012-10-23 20:34:12 UTC) #4
Leon
11 years, 6 months ago (2012-10-26 19:43:59 UTC) #5
https://codereview.appspot.com/6755043/diff/2001/threads/countdown.cc
File threads/countdown.cc (right):

https://codereview.appspot.com/6755043/diff/2001/threads/countdown.cc#newcode6
threads/countdown.cc:6: ready_.Lock();
Would it be faster (and just as safe) to use atomic decrement to avoid some
locking and signaling?
Run() {
  if (sk_atomic_dec(&n_) == 1) { // sk_atomic_dec subtracts one and returns the
original value
    ready_.Lock();
    ready_.Signal();
    ready_.Unlock();
  }
}

Wait() {
  ready_.Lock();
  while (n_ > 0) {
    ready_.Wait();
  }
  ready_.Unlock();
}

https://codereview.appspot.com/6755043/diff/2001/threads/countdown.cc#newcode16
threads/countdown.cc:16: }
Doesn't Wait() lock once it resumes? Shouldn't we call

ready_.Unlock()

here?

https://codereview.appspot.com/6755043/diff/2001/threads/threadpool.h
File threads/threadpool.h (right):

https://codereview.appspot.com/6755043/diff/2001/threads/threadpool.h#newcode22
threads/threadpool.h:22: void Add(Runnable*);
I want each thread to be able to call the function to create the TLS font data.
It might be nice to have a way to ensure that happens. Maybe something like
AddOnAllThreads? Or maybe a Runnable could be passed to the constructor to run
once at the beginning.

(Alternatively, I can call the function before each draw; it won't break
anything but might slow things down.)
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b