Multi Processors in Ruby
-
I was just explaining to a client why SketchUp is slower on his new Quad machine than on his old single core machine. I'm sure I didn't have it right - but I assumed that each on of the 4 processors on the new machine is slower then the single processor on his old machine, and that SketchUp can only use one processor. Does that seem logical.
Here is the real question for this thread. If I use UI.timer to start new threads in Ruby, is it possible that I might be able to do things in SketchUp in parallel (under tightly controlled circumstances - such as having each of two fetch data from every-other entity in the drawing. Has anyone ever tried this?
It seems like if we could write some special multi-threading tools in Ruby we could help SketchUp survive in the multi-processor world??? (As a CAD developer I know there are many things you cannot do - such as having both threads change the drawing at the same time, but there are other things which might be possible - especially when searching or extracting data)
-
I think I'm right in saying that Ruby doesn't support placed processes/threads. ie Its threading is just a very simple scheduling within the process in which it was spawned. So you get no performance gain by threading within Ruby.
Adam
-
funny thing - I did a Test.time_display 1000 on my quadcore and all 4 core are used by Sketchup process
-
Yes, expected behaviour. A task will be farmed out to 'a core' - any core.
But you can't place processes on processors/cores and therefore you don't get true concurrency.
Adam
-
@unknownuser said:
funny thing - I did a Test.time_display 1000 on my quadcore and all 4 core are used by Sketchup process
But did you ever get SketchUp to use more than 25% of the total processor time? (with 4 cores)
-
Adam: I put SU on core 0 and 3 and both cores were running at 85-95%
Al: max was 45% on all 4 cores
-
Don't confuse the real threads within an Application and the Thread objects in Ruby. We're speaking of the latter here.
I could easily believe that SU has a bunch of threads doing stuff that if given the opportunity will be placed by the scheduler on different cores - hence the result you're seeing TBD. The original question was about leveraging cores from Ruby.
However, the broader issue of making SU use multi-core machines in a scaleable way (ie double the cores, roughly double the performance) is tricky because I suspect much of what SU does internally doesn't parallelize very well. Be interesting to know where the time in SU goes...
And the even broader issue is that in software engineering generally, we're still using the same old patterns for much of our codebases that simply doesn't fit well with a platform with many cores - much of what we do is very procedural - invoke a function, get an answer - which is just not how these platforms want to be driven. (They want more the flavor of here's 50 calls to that function and I'll pick up the answers sometime later).
How you gonna map SU to Larabee, Mr. Sketchup?
Adam
-
I suspect I'm just going to have to try this when I get a chance.
One of the reasons that a CAD system like SketchUp has a hard time using multiple cores, is that you can only assign tasks to multiple cores when there are two (or more) tasks you can do at the same time.
In our rendering engine, we can process rendering for one horizontal scan line in one task, while we are processing pixels in the next scan line in another task.
A similar example in a CAD system would be for reading through the drawing.
For instance if you were searching for something in the model which took an appreciable amount of time, you could search half the entities in one task and the other half in another task.
But this gets much trickier if you are searching and modifying at the same time, because now you would be modifying the drawing, and this might make things difficult for the other task (if anything internally gets changes or moved).
I was just interested in:
-
Is it possible to access the sketchup database separately from multiple tasks in Ruby
-
If so, can we think of any task which takes a lot of time which we could speed up.
Of course, it would be even better if the SketchUp development team would try to see what things they could multi-task. But, while we are waiting, perhaps the "ruby" crew could think of some ideas.
-
-
@al hart said:
I was just interested in:
- Is it possible to access the sketchup database separately from multiple tasks in Ruby
Ruby doesn't 'do' concurrent tasks. So the answer is No!
Adam
Advertisement