Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 0837A1083 for ; Tue, 15 Sep 2015 09:55:58 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D0D1EF4 for ; Tue, 15 Sep 2015 09:55:55 +0000 (UTC) Received: by wicgb1 with SMTP id gb1so20602733wic.1 for ; Tue, 15 Sep 2015 02:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=LM0rOkg+2ocxmC3gCRQwkxDFkTgX+LJqFOfAsCvWKU0=; b=0jIaLZtKMevVWC2RUyd/E4oJi4xGVsq1aAWispNF9X2t1PU0z4CZIydqgHhrp1a4+a l9uy0LniSVqteZyr4nOKJbg0FggglRe8/jXFSYguhT01mz/fmtJX4nKXjMkYtrjMncbt irwypLAcfUfmE4AbB7JEGazvajgNJHG0lhLMioLuXkWcpNhGRgbQTJWiR63lMvh+E0we FGNz8vgx3N4x1UgmBBMnQbOBIaZ5xJJKDrj9GAvGy3SY2uBrSnBDCGKMejXoOJisSmu5 SMl72/PQtazgUmuDPa9ozo7J30YCH2w1N4f+9hSIu1wB2qOO5LQ8DzunjMZD9LYonP6I l83g== X-Received: by 10.194.191.164 with SMTP id gz4mr38198735wjc.21.1442310954284; Tue, 15 Sep 2015 02:55:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.21.200 with HTTP; Tue, 15 Sep 2015 02:55:34 -0700 (PDT) In-Reply-To: References: From: Btc Drak Date: Tue, 15 Sep 2015 10:55:34 +0100 Message-ID: To: Jeff Garzik Content-Type: multipart/alternative; boundary=047d7ba9821215fdeb051fc630bb X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, HK_RANDOM_ENVFROM, HK_RANDOM_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Bitcoin development mailing list Subject: Re: [bitcoin-dev] libconsensus and bitcoin development process X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Development Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Sep 2015 09:55:58 -0000 --047d7ba9821215fdeb051fc630bb Content-Type: text/plain; charset=UTF-8 I also share a lot of Jeff's concerns about refactoring and have voiced them several times on IRC and in private to Jorge, Wladamir and Greg. I meant to do a write up but never got around to it. Jeff has quite eloquently stated the various problems. I would like to share my thoughts on the matter because we really do need to come up with a plan on how this issue is dealt with. Obviously, Bitcoin Core is quite tightly coupled at the moment and definitely needs extensive modularisation. Such work will inevitably require lots of bulk code moves and then finer refactoring. However, it requires proper planning because there are lots of effects and consequences for other people contributing to Core and also downstream projects relying on Core: 1. Refactoring often causes other pull requests to diverge and require rebasing. Continual refactoring can put PRs in "rebase hell" and puts a big stress on contributors (many of whom are part time). 2. Version to version, Bitcoin Core changes significantly in structure. 0.9 to 0.10 is unrecognisable. 0.10 to 0.11 is even more so. This makes makes it hard to follow release to release and the net result is less people upgrade (especially think of miners trying to keep their patch sets working while trying not to disrupt or risk their mining operations). 3. Continual refactoring increases risk: we're human, and mistakes will slip through peer review. This is especially concerning with consensus critical code and this makes it difficult to merge such refactoring often, which of course exacerbates the problem. The net negative consequence is it is harder to contribute to Core, harder for the Core maintainers to merge and harder for downstream/dependent projects/implementations to keep up. Suggested Way Forward --------------------------------- With the understanding that refactored code by definition must not change behaviour. There are three major kinds of refactoring: 1. code moves (e.g. separating concerns into different files); 2. code style; 3. structural optimisation and consolidation (reducing LOC, separating concerns, encapsulation etc). Code moves(1) and CS(2) are easy to peer review and merge quickly. The third kind(3) requires deeper analysis to ensure that while the code changed, the behaviour (including any bugs) did not. We must resist all temptation to fix bugs or tack on minor fixes and tweaks during refactoring: pull requests should only be refactoring only, with no net change to behaviour. Keeping discipline makes it much easier to verify and peer review and this faster to merge. With respect to Code moves and CS, I believe we should have a "refactoring fortnight" where we so the bulk of code move-only refactoring plus CS where necessary. This is by fat the most disruptive kind of change because it widely affects other PRs mergeability. We should aim to get most of this done in one go, so that it's not happening in dribs and drabs over months and many releases. Once done, it gives everyone a good idea to the overall new structure and where one can expect to find things in the future. The idea here is to help orientation and not have to continuously hunt for where things have moved to. To be clear, I am strongly suggesting code move-only refactoring PRs not be mixed with anything else. Same for CS changes. This makes the PRs extremely easy to vet and thus quick to merge. Towards this end, maybe there should be an IRC meeting to agree the initial moves, then someone who has the stomach for it can get on and do it - during that time, we do not merge anything else. We need to bite the bullet and break the back out of code moves. With regards to CS, I think we do need to get CS right, because a continual dribble of CS changes also makes diffs between releases less easy to follow. Much of CS checking can be automated by the continuous integration so authors can get it right easily. It can be just like a Travis check. With respect to the 3rd kind of refactoring, we need to set some standards and goals and aim for some kind of consistency. Refactoring needs to fulfil certain goals and criterion otherwise contributors will always find a reason to fiddle over and over forever. Obvious targets here can be things like proper encapsulation and separation of concerns. Overall, refactoring should be merged quickly, but only on a schedule so it doesn't cause major disruption to others. Obviously the third kind of refactoring more complex and time consuming and will need to occur over time, but it should happen in defined steps. As Jeff said, one week a month, or maybe one month a release. In any case, refactoring changes should be quickly accepted or rejected by the project maintainer and not left hanging. Finally, refactoring should *always* be uncontroversial because essentially functionality is not changing. If functionality changes (e.g. you try to sneak in a big fix or feature tweak "because it's small") the PR should be rejected outright. Additionally, if we break down refactoring into the three kinds stated above, peer review will be much more straightforward. On Tue, Sep 15, 2015 at 5:10 AM, Jeff Garzik via bitcoin-dev < bitcoin-dev@lists.linuxfoundation.org> wrote: > [collating a private mail and a github issue comment, moving it to a > better forum] > > On libconsensus > --------------- > In general there exists the reasonable goal to move consensus state > and code to a specific, separate lib. > > To someone not closely reviewing the seemingly endless stream of > libconsensus refactoring PRs, the 10,000 foot view is that there is a > rather random stream of refactors that proceed in fits and starts > without apparent plan or end other than a one sentence "isolate > consensus state and code" summary. > > I am hoping that > * There is some plan > * We will not see a five year stream of random consensus code movement > patches causing lots of downstream developer headaches. > > I read every code change in every pull request that comes into > github/bitcoin/bitcoin with three exceptions: > * consensus code movement changes - too big, too chaotic, too > frequent, too unfocused, laziness guarantees others will inevitably > ACK it without me. > * some non-code changes (docs) > * ignore 80% of the Qt changes > > As with any sort of refactoring, they are easy to prove correct, easy > to reason, and therefore quick and easy to ACK and merge. > > Refactors however have a very real negative impact. > bitcoin/bitcoin.git is not only the source tree in the universe. > Software engineers at home, at startups, and at major companies are > maintaining branches of their own. > > It is very very easy to fall into a trap where a project is merging > lots of cosmetic changes and not seeing the downstream ripple effects. > Several people complained to me at the conference about all the code > movement changes breaking their own work, causing them to stay on > older versions of bitcoin due to the effort required to rebase to each > new release version - and I share those complaints. > > Complex code changes with longer development cycles than simple code > movement patches keep breaking. It is very frustrating, and causes > folks to get trapped between a rock and a hard place: > - Trying to push non-trivial changes upstream is difficult, for normal > and reasonable reasons (big important changes need review etc.). > - Maintaining non-trivial changes out of tree is also painful, for the > aforementioned reasons. > > Reasonable work languishes in constant-rebase hell, and incentivizes > against keeping up with the latest tree. > > > Aside from the refactor, libconsensus appears to be engineering in the > dark. Where is any sort of plan? I have low standards - a photo of a > whiteboard or youtube clip will do. > > The general goal is good. But we must not stray into unfocused > engineering for a non-existent future library user. > > The higher priority must be given to having a source code base that > maximizes the collective developers' ability to maintain The Router -- > the core bitcoin full node P2P engine. > > I recommend time-based bursts of code movement changes. See below; > for example, just submit & merge code movement changes on the first > week of every 2nd month. Code movement changes are easy to create > from scratch once a concrete goal is known. The coding part is > trivial and takes no time. > > As we saw in the Linux kernel - battle lessons hard learned - code > movement and refactors have often unseen negative impact on downstream > developers working on more complicated changes that have more positive > impact to our developers and users. > > > On Bitcoin development release cycles & process > ------------------------------------------------------------------ > > As I've outlined in the past, the Linux kernel maintenance phases > address some of these problems. The merge window into git master > opens for 1 week, a very chaotic week full of merging (and rebasing), > and then the merge window closes. Several weeks follow as the "dust > settles" -- testing, bug fixing, moving in parallel OOB with > not-yet-ready development. Release candidates follow, then the > release, then the cycle repeats. > > IMO a merge window approach fixes some of the issues with refactoring, > as well as introduces some useful -developer discipline- into the > development process. Bitcoin Core still needs rapid iteration -- > another failing of the current project -- and so something of a more > rapid pace is needed: > - 1st week of each month, merge changes. Lots of rebasing during this > week. > - remaining days of the month, test, bug fix > - release at end of month > > If changes are not ready for merging, then so be it, they wait until > next month's release. Some releases have major features, some > releases are completely boring and offer little of note. That is the > nature of time-based development iteration. It's like dollar cost > averaging, a bit. > > > And frankly, I would like to close all github pull requests that are > not ready to merge That Week. I'm as guilty of this as any, but that > stuff just languishes. Excluding a certain category of obvious-crap, > pull requests tend to default to a state of either (a) rapid merging, > (b) months-long issues/projects, (c) limbo. > > Under a more time-based approach, a better pull request process would be to > * Only open pull requests if it's a bug fix, or the merge window is > open and the change is ready to be merged in the developer's opinion. > * Developers CC bitcoin-dev list to discuss Bitcoin Core-bound projects > * Developers maintain and publish projects via their own git trees > * Pull requests should be closed if unmerged after 7 days, unless it > is an important bug fix etc. > > The problem with projects like libconsensus is that they can get > unfocused and open ended. Code movement changes in particular are > cheap to generate. It is low developer cost for the developer to > iterate all the way to the end state, see what that looks like, and > see if people like it. That end state is not something you would > merge all in one go. I would likely stash that tree, and then start > again, seek the most optimal and least disruptive set of refactors, > and generate and merge those into bitcoin/bitcoin.git in a time-based, > paced manner. Announce the pace ahead of time - "cosmetic stuff that > breaks your patches will be merged 1st week of every second month" > > To underscore, the higher priority must be given to having a source > code base and disciplined development process that maximizes the > collective developers' ability to maintain The Router that maintains > most of our network. > > Modularity, refactoring, cleaning up grotty code generates a deep > seated happiness in many engineers. Field experience however shows > refactoring is a never ending process which sometimes gets in the way > of More Important Work. > _______________________________________________ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > --047d7ba9821215fdeb051fc630bb Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I also share a lot of Jeff's concerns about refac= toring and have voiced them several times on IRC and in private to Jorge, W= ladamir and Greg. I meant to do a write up but never got around to it. Jeff= has quite eloquently stated the various problems. I would like to share my= thoughts on the matter because we really do need to come up with a plan on= how this issue is dealt with.

Obviously, Bitc= oin Core is quite tightly coupled at the moment and definitely needs extens= ive modularisation. Such work will inevitably require lots of bulk code mov= es and then finer refactoring. However, it requires proper planning because= there are lots of effects and consequences for other people contributing t= o Core and also downstream projects relying on Core:=C2=A0

1. Refactoring often causes other pull requests to diverge and req= uire rebasing. Continual refactoring can put PRs in "rebase hell"= and puts a big stress on contributors (many of whom are part time).
<= div>
2. Version to version, Bitcoin Core changes significantl= y in structure. 0.9 to 0.10 is unrecognisable. 0.10 to 0.11 is even more so= . This makes makes it hard to follow release to release and the net result = is less people upgrade (especially think of miners trying to keep their pat= ch sets working while trying not to disrupt or risk their mining operations= ).

3. Continual refactoring increases risk: we'= ;re human, and mistakes will slip through peer review. This is especially c= oncerning with consensus critical code and this makes it difficult to merge= such refactoring often, which of course exacerbates the problem.=C2=A0

The net negative consequence is it is harder to contr= ibute to Core, harder for the Core maintainers to merge and harder for down= stream/dependent projects/implementations to keep up.

<= div>Suggested Way Forward
---------------------------------

With the understanding that refactored code by defi= nition must not change behaviour. There are three major kinds of refactorin= g:=C2=A0

1. code moves (e.g. separating concer= ns into different files);
2. code style;
3. structural = optimisation and consolidation (reducing LOC, separating concerns, encapsul= ation etc).=C2=A0

Code moves(1) and CS(2) are easy= to peer review and merge quickly. The third kind(3) requires deeper analys= is to ensure that while the code changed, the behaviour (including any bugs= ) did not.

We must resist all temptation to fi= x bugs or tack on minor fixes and tweaks during refactoring: pull requests = should only be refactoring only, with no net change to behaviour. Keeping d= iscipline makes it much easier to verify and peer review and this faster to= merge.

With respect to=C2=A0Code moves and CS,=C2= =A0I believe we should have a "refactoring fortnight" where we so= the bulk of code move-only refactoring plus CS where necessary. This is by= fat the most disruptive kind of change because it widely affects other PRs= mergeability. We should aim to get most of this done in one go, so that it= 's not happening in dribs and drabs over months and many releases. Once= done, it gives everyone a good idea to the overall new structure and where= one can expect to find things in the future. The idea here is to help orie= ntation and not have to continuously hunt for where things have moved to.

To be clear, I am strongly suggesting code move-onl= y refactoring PRs not be mixed with anything else. Same for CS changes. Thi= s makes the PRs extremely easy to vet and thus quick to merge.
Towards this end, maybe there should be an IRC meeting to= agree the initial moves, then someone who has the stomach for it can get o= n and do it - during that time, we do not merge anything else. We need to b= ite the bullet and break the back out of code moves.=C2=A0
<= div>
With regards to CS, I think we do need to get CS right, = because a continual dribble of CS changes also makes diffs between releases= less easy to follow. Much of CS checking can be automated by the continuou= s integration so authors can get it right easily. It can be just like a Tra= vis check.

With respect to the 3rd kind of refacto= ring, we need to set some standards and goals and aim for some kind of cons= istency. Refactoring needs to fulfil certain goals and criterion otherwise = contributors will always find a reason to fiddle over and over forever. Obv= ious targets here can be things like proper encapsulation and separation of= concerns.

Overall, refactoring should be merg= ed quickly, but only on a schedule so it doesn't cause major disruption= to others.=C2=A0

Obviously the third kind of refa= ctoring more complex and time consuming and will need to occur over time, b= ut it should happen in defined steps. As Jeff said, one week a month, or ma= ybe one month a release. In any case, refactoring changes should be quickly= accepted or rejected by the project maintainer and not left hanging.=C2=A0=

Finally, refactoring should *always* be uncontrov= ersial because essentially functionality is not changing. If functionality = changes (e.g. you try to sneak in a big fix or feature tweak "because = it's small") the PR should be rejected outright. Additionally, if = we break down refactoring into the three kinds stated above, peer review wi= ll be much more straightforward.=C2=A0


<= div class=3D"gmail_extra">
On Tue, Sep 15, 20= 15 at 5:10 AM, Jeff Garzik via bitcoin-dev <bitcoin-de= v@lists.linuxfoundation.org> wrote:
[collating a private mail and a github issue comment, moving it to= a
better forum]

On libconsensus
---------------
In general there exists the reasonable goal to move consensus state
and code to a specific, separate lib.

To someone not closely reviewing the seemingly endless stream of
libconsensus refactoring PRs, the 10,000 foot view is that there is a
rather random stream of refactors that proceed in fits and starts
without apparent plan or end other than a one sentence "isolate
consensus state and code" summary.

I am hoping that
* There is some plan
* We will not see a five year stream of random consensus code movement
patches causing lots of downstream developer headaches.

I read every code change in every pull request that comes into
github/bitcoin/bitcoin with three exceptions:
* consensus code movement changes - too big, too chaotic, too
frequent, too unfocused, laziness guarantees others will inevitably
ACK it without me.
* some non-code changes (docs)
* ignore 80% of the Qt changes

As with any sort of refactoring, they are easy to prove correct, easy
to reason, and therefore quick and easy to ACK and merge.

Refactors however have a very real negative impact.
bitcoin/bitcoin.git is not only the source tree in the universe.
Software engineers at home, at startups, and at major companies are
maintaining branches of their own.

It is very very easy to fall into a trap where a project is merging
lots of cosmetic changes and not seeing the downstream ripple effects.
Several people complained to me at the conference about all the code
movement changes breaking their own work, causing them to stay on
older versions of bitcoin due to the effort required to rebase to each
new release version - and I share those complaints.

Complex code changes with longer development cycles than simple code
movement patches keep breaking.=C2=A0 It is very frustrating, and causes folks to get trapped between a rock and a hard place:
- Trying to push non-trivial changes upstream is difficult, for normal
and reasonable reasons (big important changes need review etc.).
- Maintaining non-trivial changes out of tree is also painful, for the
aforementioned reasons.

Reasonable work languishes in constant-rebase hell, and incentivizes
against keeping up with the latest tree.


Aside from the refactor, libconsensus appears to be engineering in the
dark.=C2=A0 Where is any sort of plan?=C2=A0 I have low standards - a photo= of a
whiteboard or youtube clip will do.

The general goal is good.=C2=A0 =C2=A0But we must not stray into unfocused<= br> engineering for a non-existent future library user.

The higher priority must be given to having a source code base that
maximizes the collective developers' ability to maintain The Router --<= br> the core bitcoin full node P2P engine.

I recommend time-based bursts of code movement changes.=C2=A0 See below; for example, just submit & merge code movement changes on the first
week of every 2nd month.=C2=A0 Code movement changes are easy to create
from scratch once a concrete goal is known.=C2=A0 The coding part is
trivial and takes no time.

As we saw in the Linux kernel - battle lessons hard learned - code
movement and refactors have often unseen negative impact on downstream
developers working on more complicated changes that have more positive
impact to our developers and users.


On Bitcoin development release cycles & process
------------------------------------------------------------------

As I've outlined in the past, the Linux kernel maintenance phases
address some of these problems.=C2=A0 The merge window into git master
opens for 1 week, a very chaotic week full of merging (and rebasing),
and then the merge window closes.=C2=A0 Several weeks follow as the "d= ust
settles" -- testing, bug fixing, moving in parallel OOB with
not-yet-ready development.=C2=A0 Release candidates follow, then the
release, then the cycle repeats.

IMO a merge window approach fixes some of the issues with refactoring,
as well as introduces some useful -developer discipline- into the
development process.=C2=A0 Bitcoin Core still needs rapid iteration --
another failing of the current project -- and so something of a more
rapid pace is needed:
- 1st week of each month, merge changes.=C2=A0 Lots of rebasing during this= week.
- remaining days of the month, test, bug fix
- release at end of month

If changes are not ready for merging, then so be it, they wait until
next month's release.=C2=A0 Some releases have major features, some
releases are completely boring and offer little of note.=C2=A0 That is the<= br> nature of time-based development iteration.=C2=A0 It's like dollar cost=
averaging, a bit.


And frankly, I would like to close all github pull requests that are
not ready to merge That Week.=C2=A0 I'm as guilty of this as any, but t= hat
stuff just languishes.=C2=A0 Excluding a certain category of obvious-crap,<= br> pull requests tend to default to a state of either (a) rapid merging,
(b) months-long issues/projects, (c) limbo.

Under a more time-based approach, a better pull request process would be to=
* Only open pull requests if it's a bug fix, or the merge window is
open and the change is ready to be merged in the developer's opinion. * Developers CC bitcoin-dev list to discuss Bitcoin Core-bound projects
* Developers maintain and publish projects via their own git trees
* Pull requests should be closed if unmerged after 7 days, unless it
is an important bug fix etc.

The problem with projects like libconsensus is that they can get
unfocused and open ended.=C2=A0 Code movement changes in particular are
cheap to generate.=C2=A0 It is low developer cost for the developer to
iterate all the way to the end state, see what that looks like, and
see if people like it.=C2=A0 That end state is not something you would
merge all in one go.=C2=A0 I would likely stash that tree, and then start again, seek the most optimal and least disruptive set of refactors,
and generate and merge those into bitcoin/bitcoin.git in a time-based,
paced manner.=C2=A0 Announce the pace ahead of time - "cosmetic stuff = that
breaks your patches will be merged 1st week of every second month"

To underscore, the higher priority must be given to having a source
code base and disciplined development process that maximizes the
collective developers' ability to maintain The Router that maintains most of our network.

Modularity, refactoring, cleaning up grotty code generates a deep
seated happiness in many engineers.=C2=A0 Field experience however shows refactoring is a never ending process which sometimes gets in the way
of More Important Work.
_______________________________________________
bitcoin-dev mailing list
= bitcoin-dev@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mail= man/listinfo/bitcoin-dev

--047d7ba9821215fdeb051fc630bb--