Bug 49768

Summary: nrwt multiprocessing - add 'worker number' concept, move stuff to worker thread
Product: WebKit Reporter: Dirk Pranke <dpranke>
Component: New BugsAssignee: Dirk Pranke <dpranke>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, eric, hayato, ojan, tony
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Bug Depends on:    
Bug Blocks: 49566, 49779    
Attachments:
Description Flags
Patch
none
minor cleanup
none
review feedback - sort imports alphabetically none

Description Dirk Pranke 2010-11-18 16:22:23 PST
nrwt multiprocessing - add 'worker number' concept, move stuff to worker thread
Comment 1 Dirk Pranke 2010-11-18 16:24:01 PST
Created attachment 74316 [details]
Patch
Comment 2 Dirk Pranke 2010-11-18 16:42:42 PST
Created attachment 74321 [details]
minor cleanup
Comment 3 Tony Chang 2010-11-18 17:44:17 PST
Comment on attachment 74321 [details]
minor cleanup

View in context: https://bugs.webkit.org/attachment.cgi?id=74321&action=review

> WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:55
> +from webkitpy.layout_tests.test_types import test_type_base
> +from webkitpy.layout_tests.test_types import text_diff
> +from webkitpy.layout_tests.test_types import image_diff

Nit: Sort alphabetically

> WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:486
> +                                  self._worker_number,
> +                                  self._name,

It seems redundant to have to pass worker number and worker name.  Are there cases where you can't derive the name from the number?  Maybe there should just be a static function somewhere that converts number to name?
Comment 4 Dirk Pranke 2010-11-18 18:19:25 PST
Created attachment 74335 [details]
review feedback - sort imports alphabetically
Comment 5 Dirk Pranke 2010-11-18 18:21:31 PST
(In reply to comment #3)
> (From update of attachment 74321 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=74321&action=review
> 
> > WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:55
> > +from webkitpy.layout_tests.test_types import test_type_base
> > +from webkitpy.layout_tests.test_types import text_diff
> > +from webkitpy.layout_tests.test_types import image_diff
> 
> Nit: Sort alphabetically
>

Done.
 
> > WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:486
> > +                                  self._worker_number,
> > +                                  self._name,
> 
> It seems redundant to have to pass worker number and worker name.  Are there cases where you can't derive the name from the number?  Maybe there should just be a static function somewhere that converts number to name?

In fact, if you look at older versions of the rollup patches that's what I used to have. Then I realized that there's no reason for SingleTestThread to know that you can derive worker_name from worker_number, and that this better encapsulate things. I'd prefer to leave it as it is.
Comment 6 Tony Chang 2010-11-19 09:37:42 PST
Comment on attachment 74335 [details]
review feedback - sort imports alphabetically

View in context: https://bugs.webkit.org/attachment.cgi?id=74335&action=review

> WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:171
> +    def __init__(self, port, options, worker_number, worker_name,
> +                 test_input, test_types, test_args):

My main concern with having a separate name and number is that it makes functions with lots of parameters fragile.  Since there's no compile time checking of parameters, it's easy to miss a caller and break things when refactoring.

In this case, it's relatively isolated (only this call takes both), so I don't feel that strongly about it.  This patch doesn't use worker_number, do you need it in the future?  Maybe it should be added when it's used?
Comment 7 Tony Chang 2010-11-19 09:39:03 PST
Another option for encapsulating is to make a small class that combines worker name and number.  You could have a getter on the class that derives the name from the number.
Comment 8 Dirk Pranke 2010-11-19 10:14:09 PST
(In reply to comment #6)
> (From update of attachment 74335 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=74335&action=review
> 
> > WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:171
> > +    def __init__(self, port, options, worker_number, worker_name,
> > +                 test_input, test_types, test_args):
> 
> My main concern with having a separate name and number is that it makes functions with lots of parameters fragile.  Since there's no compile time checking of parameters, it's easy to miss a caller and break things when refactoring.
> 

It's a fair concern. A bunch of these arguments go away in subsequent patches.
Comment 9 Dirk Pranke 2010-11-19 17:50:02 PST
Comment on attachment 74335 [details]
review feedback - sort imports alphabetically

Clearing flags on attachment: 74335

Committed r72458: <http://trac.webkit.org/changeset/72458>
Comment 10 Dirk Pranke 2010-11-19 17:50:07 PST
All reviewed patches have been landed.  Closing bug.