Menu

#5949 Add option to use Ghostscript API instead of forking

Fixed
2020-05-10
2020-04-30
No

Add option to use Ghostscript API instead of forking

This is much more efficient than the current scheme when converting
many PostScript files, for example when building the documentation.
For the Notation Reference, lilypond-book now takes ~2m30s instead
of 5m to compile all snippets from the notation.tely file. Other
manuals benefit less, but still the time for 'make doc' on my system
improves by one third from around 33m to 22m.

An alternative would have been to always call gsapi_init_with_args
with the same arguments used until now. This indeed works and avoids
the overhead of forking, but the instance cannot be reused. Calling
gsapi_new_instance -> gsapi_init_with_args -> gsapi_delete_instance
for every conversion still means a lot of overhead and a prototype
suggested only a small gain compared to the previous solution.

This is not the default because recent versions of Ghostscript are
distributed under the AGPL and it's unclear what the implications of
linking to the library is. If built with support for the API, use
-dgs-api=#f to still fork the gs command.

http://codereview.appspot.com/548030043

Discussion

  • Anonymous

    Anonymous - 2020-05-01

    Fails make

    ..
    Making lily/out/context-def.o < cc
    Making lily/out/general-scheme.o < cc
    Making lily/out/system.o < cc
    /home/james/lilypond-git/lily/general-scheme.cc:41:10: fatal error: ghostscript/iapi.h: No such file or directory
     #include <ghostscript/iapi.h>
              ^~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    /home/james/lilypond-git/build/../stepmake/stepmake/c++-rules.make:4: recipe for target 'out/general-scheme.o' failed
    make[1]: *** [out/general-scheme.o] Error 1
    make[1]: *** Waiting for unfinished jobs....
    /home/james/lilypond-git/lily/system.cc: In member function 'void System::add_column(Paper_column*)':
    /home/james/lilypond-git/lily/system.cc:513:25: warning: conversion to 'int' from 'vsize {aka long unsigned int}' may alter its value [-Wconversion]
       p->set_rank (ga->size ());
                    ~~~~~~~~~^~
    /home/james/lilypond-git/build/../stepmake/stepmake/generic-targets.make:6: recipe for target 'all' failed
    make: *** [all] Error 2
    
     
    • Jonas Hahnfeld

      Jonas Hahnfeld - 2020-05-01

      Did you regenerate configure? It should have complained about a missing dependency. On Ubuntu you need to install the libgs-dev package.

      Anyway after feedback from Han-Wen I will update the patch and guard this by an optional configure flag. So no need to re-test the current Patch Set.

       
  • Anonymous

    Anonymous - 2020-05-01
    • Description has changed:

    Diff:

    
    
    • Needs: -->
    • Patch: new --> needs_work
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-05-02

    Add option to use Ghostscript API instead of forking

    http://codereview.appspot.com/548030043

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-05-02
    • summary: Use GhostScript API instead of forking --> Add option to use Ghostscript API instead of forking
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -Use GhostScript API instead of forking
    +Add option to use Ghostscript API instead of forking
    
     This is much more efficient than the current scheme when converting
     many PostScript files, for example when building the documentation.
    @@ -14,4 +14,8 @@
     for every conversion still means a lot of overhead and a prototype
     suggested only a small gain compared to the previous solution.
    
    +This is not the default because recent versions of Ghostscript are
    +distributed under the AGPL and it&#39;s unclear what the implications of
    +linking to the library is.
    +
     http://codereview.appspot.com/548030043
    
    • Needs: -->
    • Type: -->
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-05-02
     
  • Anonymous

    Anonymous - 2020-05-02
    • Needs: -->
    • Patch: new --> needs_work
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-05-02

    Patch doesn't apply to current master

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-05-03

    rebase + allow -dgs-api=#f to still fork

    http://codereview.appspot.com/548030043

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-05-03
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -16,6 +16,7 @@
    
     This is not the default because recent versions of Ghostscript are
     distributed under the AGPL and it&#39;s unclear what the implications of
    -linking to the library is.
    +linking to the library is. If built with support for the API, use
    +-dgs-api=#f to still fork the gs command.
    
     http://codereview.appspot.com/548030043
    
    • Needs: -->
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-05-03
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-05-03

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2020-05-07
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-05-07

    Patch on countdown for May 9th

     
  • Anonymous

    Anonymous - 2020-05-09
    • Patch: countdown --> push
     
  • Anonymous

    Anonymous - 2020-05-09

    Patch counted down - please push

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-05-10
    • labels: --> Fixed_2_21_2
    • status: Started --> Fixed
    • Patch: push -->
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-05-10
    commit ddfd0b4fb548aa32bfd809014502de0666d514f3
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Mon Apr 27 20:54:43 2020 +0200
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Sat May 9 20:04:45 2020 +0200
    
        Issue 5949: Add option to use Ghostscript API instead of forking
    
        This is much more efficient than the current scheme when converting
        many PostScript files, for example when building the documentation.
        For the Notation Reference, lilypond-book now takes ~2m30s instead
        of 5m to compile all snippets from the notation.tely file. Other
        manuals benefit less, but still the time for 'make doc' on my system
        improves by one third from around 33m to 22m.
    
        An alternative would have been to always call gsapi_init_with_args
        with the same arguments used until now. This indeed works and avoids
        the overhead of forking, but the instance cannot be reused. Calling
        gsapi_new_instance -> gsapi_init_with_args -> gsapi_delete_instance
        for every conversion still means a lot of overhead and a prototype
        suggested only a small gain compared to the previous solution.
    
        This is not the default because recent versions of Ghostscript are
        distributed under the AGPL and it's unclear what the implications of
        linking to the library is. If built with support for the API, use
        -dgs-api=#f to still fork the gs command.