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

Issue 547980044: Rewrite Skyline code

Can't Edit
Can't Publish+Mail
Start Review
Created:
4 years ago by hanwenn
Modified:
3 years, 12 months ago
Reviewers:
dak, Dan Eble, hahnjo
CC:
lilypond-devel_gnu.org
Visibility:
Public.

Description

Rewrite Skyline code * Do not use contiguous buildings. Instead, Y=-infinity is represented by simply omitting the building. This reduces memory requirements (for example, an empty skyline needs no buildings at all.), and obviates the Skyline::normalize() call which takes ~1 % of CPU. * Buildings store Y coordinate of the left edge, rather than the intercept at x==0.0. This avoid excessive rounding problems when X is large, and lets us compute building.height_at(x[LEFT]) cheaply. * Avoid using infinity and NaN. We only let the X coordinates at the edges be infinite (which is only necessary if a minimum height is specified) * Simplify the merge code, using less nested if statements. * Add a unittest for the Skyline code * Debug output is produced with Lookup::segments_to_line_stencil() * Consolidate print and print_points

Patch Set 1 #

Total comments: 4

Patch Set 2 : don't trim zero width buildings #

Total comments: 9

Patch Set 3 : get rid of interval #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+680 lines, -469 lines) Patch
A input/regression/unittests.ly View 1 chunk +5 lines, -0 lines 0 comments Download
M lily/axis-group-interface.cc View 1 chunk +6 lines, -4 lines 0 comments Download
M lily/include/lookup.hh View 1 chunk +1 line, -0 lines 0 comments Download
M lily/include/skyline.hh View 1 2 2 chunks +64 lines, -29 lines 1 comment Download
M lily/include/skyline-pair.hh View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M lily/lookup.cc View 1 chunk +13 lines, -0 lines 0 comments Download
M lily/separation-item.cc View 1 chunk +6 lines, -2 lines 0 comments Download
M lily/skyline.cc View 1 2 13 chunks +581 lines, -422 lines 6 comments Download
M lily/skyline-pair.cc View 1 1 chunk +0 lines, -7 lines 0 comments Download
M lily/system.cc View 1 chunk +4 lines, -4 lines 0 comments Download

Messages

Total messages: 17
hanwenn
(this still needs some work, but the speedup might be worth an early look)
4 years ago (2020-04-19 21:43:26 UTC) #1
dak
On 2020/04/19 21:43:26, hanwenn wrote: > (this still needs some work, but the speedup might ...
4 years ago (2020-04-19 22:35:39 UTC) #2
Dan Eble
https://codereview.appspot.com/547980044/diff/548010043/lily/skyline.cc File lily/skyline.cc (right): https://codereview.appspot.com/547980044/diff/548010043/lily/skyline.cc#newcode348 lily/skyline.cc:348: result.push_back (buildings->at (0)); at() involves a boundary check that ...
4 years ago (2020-04-21 04:25:05 UTC) #3
hanwenn
On 2020/04/19 22:35:39, dak wrote: > On 2020/04/19 21:43:26, hanwenn wrote: > > (this still ...
4 years ago (2020-04-21 07:57:03 UTC) #4
hanwenn
https://codereview.appspot.com/547980044/diff/548010043/lily/skyline.cc File lily/skyline.cc (right): https://codereview.appspot.com/547980044/diff/548010043/lily/skyline.cc#newcode348 lily/skyline.cc:348: result.push_back (buildings->at (0)); On 2020/04/21 04:25:05, Dan Eble wrote: ...
4 years ago (2020-04-21 07:58:10 UTC) #5
hanwenn
don't trim zero width buildings
4 years ago (2020-04-24 15:50:22 UTC) #6
hahnjo
https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh File lily/include/skyline.hh (right): https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh#newcode152 lily/include/skyline.hh:152: } Why do you need all of this in ...
4 years ago (2020-04-24 16:33:05 UTC) #7
hanwenn
https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh File lily/include/skyline.hh (right): https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh#newcode152 lily/include/skyline.hh:152: } On 2020/04/24 16:33:04, hahnjo wrote: > Why do ...
4 years ago (2020-04-24 17:12:48 UTC) #8
hanwenn
On 2020/04/24 17:12:48, hanwenn wrote: > https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh > File lily/include/skyline.hh (right): > > https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh#newcode152 > ...
4 years ago (2020-04-24 17:56:36 UTC) #9
hanwenn
https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh File lily/include/skyline.hh (right): https://codereview.appspot.com/547980044/diff/567490043/lily/include/skyline.hh#newcode152 lily/include/skyline.hh:152: } On 2020/04/24 17:12:48, hanwenn wrote: > On 2020/04/24 ...
4 years ago (2020-04-24 18:51:54 UTC) #10
hanwenn
get rid of interval
4 years ago (2020-04-24 20:46:59 UTC) #11
dak
On 2020/04/19 22:35:39, dak wrote: > On 2020/04/19 21:43:26, hanwenn wrote: > > (this still ...
4 years ago (2020-04-24 23:07:56 UTC) #12
hahnjo
https://codereview.appspot.com/547980044/diff/572060043/lily/include/skyline.hh File lily/include/skyline.hh (right): https://codereview.appspot.com/547980044/diff/572060043/lily/include/skyline.hh#newcode34 lily/include/skyline.hh:34: #include "offset.hh" Please don't separate the lily includes - ...
3 years, 12 months ago (2020-04-27 07:01:28 UTC) #13
hanwenn
I'm going to put this on pause for a bit. With removing normalize() from the ...
3 years, 12 months ago (2020-04-27 21:30:18 UTC) #14
hahnjo
https://codereview.appspot.com/547980044/diff/572060043/lily/skyline.cc File lily/skyline.cc (right): https://codereview.appspot.com/547980044/diff/572060043/lily/skyline.cc#newcode175 lily/skyline.cc:175: Building front_; On 2020/04/27 21:30:18, hanwenn wrote: > On ...
3 years, 12 months ago (2020-04-28 06:49:58 UTC) #15
hanwenn
On 2020/04/28 06:49:58, hahnjo wrote: > https://codereview.appspot.com/547980044/diff/572060043/lily/skyline.cc > File lily/skyline.cc (right): > > https://codereview.appspot.com/547980044/diff/572060043/lily/skyline.cc#newcode175 > ...
3 years, 12 months ago (2020-04-28 07:20:26 UTC) #16
hahnjo
3 years, 12 months ago (2020-04-28 07:24:24 UTC) #17
On 2020/04/28 07:20:26, hanwenn wrote:
> On 2020/04/28 06:49:58, hahnjo wrote:
> > https://codereview.appspot.com/547980044/diff/572060043/lily/skyline.cc
> > File lily/skyline.cc (right):
> > 
> >
>
https://codereview.appspot.com/547980044/diff/572060043/lily/skyline.cc#newco...
> > lily/skyline.cc:175: Building front_;
> > On 2020/04/27 21:30:18, hanwenn wrote:
> > > On 2020/04/27 07:01:28, hahnjo wrote:
> > > > In any case, this causes copies on every call to next(). If you need to
> > retain
> > > > this data structure, is there a reason not to use a pointer to the
current
> > > > element? AFAICS you don't modify the underlying vector when using a
> > > > BuildingQueue
> > > 
> > > see the split_off() function.
> > 
> > That could be made a function taking an iterator as argument, or am I
missing
> > something? AFAICS it's making a copy of the current element, then modifies
> both
> > versions, and possibly advances the iterator.
> 
> Sure.
> 
> The thing I am getting at is that we spend a lot of CPU cycles for doing shift
> and raise, looping over all the elements to do trivial computations over them.
> Doing such modifications also requires making a copy of the entire thing.
> 
> If we structure this as
> 
>  
>   class Immutable_skyline : smob {
>     vector<Building>  buildings_;
>   }
> 
>   class Mutable_skyline : smob {
>      Immutable_skyline *immutable_; // potentially shared between many
> Mutable_skylines_
>      Offset  off_
>   };
> 
> we can keep work the offset handling into BuildingQueue (applying the offset
to
> each building we process in the merge). This is also better for cache
locality.

So that's a possible improvement in the future, right?
In any case, currently BuildingQueue copies to front_ while iterating over the
Buildings, even if not modifying it in all cases. That certainly doesn't sound
right.
Sign in to reply to this message.

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