Re: [Gegl-developer] BABL path vs. reference fish
On Sun, Apr 20, 2008 at 6:19 PM, Jan Heller <[EMAIL PROTECTED]> wrote: > On 00:51, Mon 14 Apr 08, Øyvind Kolås wrote: > > One issue in babl's current design is that other activity on the > > system at the same time as measuring is performed can skew results > > quite a lot for a given conversion > So these are the alternatives I came up with. If you > prefer one of these or have a better idea, I can > investigate it further. When the idea of babl originally emerged some of these questions were discussed but it none of it has been implemented yet. Giving it some thought again the direction I think would work best is most similar to your third idea. > The third possibility is again to profile longer using > getrusage or similar function, this time once per user. > The profiling results would be output e.g. to > ~/.babl/prof.data and would be reloaded next time. Once > new .so with conversion would be found or new babl version > installed, the profiling would be done again. Babl would be capable of running as it runs now without having the database but it would benefit a lot from having it. For the creation of the database I think it could be continuously updated with random samples, both from actual babl use as well as some random tests that are inserted together with some larger requested buffer conversions. What should be stored for the conversions would be the running average of all stochastic sampling and actual use. /Øyvind K. -- «The future is already here. It's just not very evenly distributed» -- William Gibson http://pippin.gimp.org/ http://ffii.org/ ___ Gegl-developer mailing list Gegl-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer
Re: [Gegl-developer] BABL path vs. reference fish
On 00:51, Mon 14 Apr 08, Øyvind Kolås wrote: > One issue in babl's current design is that other activity on the > system at the same time as measuring is performed can skew results > quite a lot for a given conversion, not sure if there is a good way to > deal with this at runtime though. Hi, yes, the gettimeofday function is indeed not the best profiling method. I have put some though into this and came up with several alternatives how to tackle this problem. The first possibility is to replace gettimeofday by system function that accounts only for time of the given process, such as getrusage. Although the getrusage function provides way to measure process time in microseconds, the real resolution is far from 1 microsecond. Using getrusage would mean that the runtime profiling would have to take approx. 100x longer than in the current state to get reasonable results for the fastest conversions. And that is far from ideal. The second possibility is to profile during the compilation, which would allow for much longer and precise profiling. This would generate some profiling data in a form of a C file and would compile into babl in the second compile pass. This might work in a situation when the compiling machine is the target machine, however, the results can be of course skewed while this is not the case. Maybe the biggest drawback would be the fact that this contradicts the dynamic paradigm of the library. The third possibility is again to profile longer using getrusage or similar function, this time once per user. The profiling results would be output e.g. to ~/.babl/prof.data and would be reloaded next time. Once new .so with conversion would be found or new babl version installed, the profiling would be done again. So these are the alternatives I came up with. If you prefer one of these or have a better idea, I can investigate it further. Regards, Jan ___ Gegl-developer mailing list Gegl-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer
Re: [Gegl-developer] BABL path vs. reference fish
On Sat, Apr 12, 2008 at 3:53 PM, Jan Heller <[EMAIL PROTECTED]> wrote: > attached is a path that introduces logic to disallow > creation of a fish path that is actually slower than > appropriate reference fish. Thank you for yet another contribution further cleaning up babl, the patch has been applied. One issue in babl's current design is that other activity on the system at the same time as measuring is performed can skew results quite a lot for a given conversion, not sure if there is a good way to deal with this at runtime though. /Øyvind K. -- «The future is already here. It's just not very evenly distributed» -- William Gibson http://pippin.gimp.org/ http://ffii.org/ ___ Gegl-developer mailing list Gegl-developer@lists.XCF.Berkeley.EDU https://lists.XCF.Berkeley.EDU/mailman/listinfo/gegl-developer
[Gegl-developer] BABL path vs. reference fish
Hi, attached is a path that introduces logic to disallow creation of a fish path that is actually slower than appropriate reference fish. Suggested Changelog entry: * babl/babl-fish-path.c (get_conversion_path), (babl_fish_path), (test_create), (init_path_instrumentation), (destroy_path_instrumentation), (get_path_instrumentation): Improved fish path instrumentation during the search for a new one to optimize for speed. Added logic to disallow creation of a fish path that is actually slower than appropriate reference fish. * babl/babl-util.[ch] (babl_process_cost): New function for unified timing formula for babl processings. * babl/babl-conversion.c (babl_conversion_error): Make use of the new babl_process_cost function. * extensions/gimp-8bit.c: Added a function declaration to prevent compiler warning. Regards, Jan Index: extensions/gimp-8bit.c === --- extensions/gimp-8bit.c (revision 304) +++ extensions/gimp-8bit.c (working copy) @@ -296,6 +296,7 @@ conv_g8_gamma_2_2_rgbaF_linear (unsigned return samples; } +int init (void); int init (void) Index: babl/babl-fish-path.c === --- babl/babl-fish-path.c (revision 304) +++ babl/babl-fish-path.c (working copy) @@ -23,7 +23,17 @@ #define BABL_MAX_COST_VALUE 200 static double -get_conversion_path_error (BablList *path); +init_path_instrumentation (Babl *fmt_source, + Babl *fmt_destination); + +static void +destroy_path_instrumentation (void); + +static void +get_path_instrumentation (BablList *path, + double *path_cost, + double *ref_cost, + double *path_error); static long process_conversion_path (BablList *path, @@ -118,28 +128,32 @@ get_conversion_path (Babl *current_forma { /* We have found a candidate path, let's * see about it's properties */ - double temp_cost = 0.0; - double temp_error = 1.0; + double path_cost = 0.0; + double ref_cost = 0.0; + double path_error = 1.0; inti; for (i = 0; i < babl_list_size (current_path); i++) { - temp_error *= (1.0 + babl_conversion_error ((BablConversion *) current_path->items[i])); - temp_cost += babl_conversion_cost ((BablConversion *) current_path->items[i]); + path_error *= (1.0 + babl_conversion_error ((BablConversion *) current_path->items[i])); } - if (temp_cost < fish_path->fish_path.cost && - temp_error - 1.0 <= legal_error () && /* check this before the next; - which does a more accurate - measurement of the error */ - (temp_error = get_conversion_path_error (current_path)) <= legal_error () - ) + if (path_error - 1.0 <= legal_error ()) /* check this before the next; + which does a more accurate + measurement of the error */ { - /* We have found the best path so far, - * let's copy it into our new fish */ - fish_path->fish_path.cost = temp_cost; - fish_path->fish.error = temp_error; - babl_list_copy (current_path, fish_path->fish_path.conversion_list); + get_path_instrumentation (current_path, &path_cost, &ref_cost, &path_error); + + if ((path_cost < ref_cost) && /* do not use paths that took longer to compute than reference */ + (path_cost < fish_path->fish_path.cost) && + (path_error <= legal_error ())) +{ + /* We have found the best path so far, + * let's copy it into our new fish */ + fish_path->fish_path.cost = path_cost; + fish_path->fish.error = path_error; + babl_list_copy (current_path, fish_path->fish_path.conversion_list); +} } } else @@ -163,11 +177,10 @@ get_conversion_path (Babl *current_forma if (!next_format->format.visited) { /* next_format is not in the current path, we can pay a visit */ - babl_list_insert_last (current_path, next_conversion); - get_conversion_path (next_format, current_length + 1, max_length); - babl_list_remove_last (current_path); - } - + babl_list_insert_last (current_path, next_conversion); + get_conversion_path (next_format, current_length + 1, max_length); + babl_list_remove_last (current_path); +} }