Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C6ADF1466 for ; Tue, 15 Sep 2015 15:26:54 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 83AE51C7 for ; Tue, 15 Sep 2015 15:26:52 +0000 (UTC) Received: by wicgb1 with SMTP id gb1so34039708wic.1 for ; Tue, 15 Sep 2015 08:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=z6pdbetvn/CNQPDtWico1kgHRuNXN9FZuAFI//44ZbQ=; b=bir65appWJbKia54Qnb/zUw3ic07eo5iEFHPUykVz7ejV82bvQlYljpMdfd3IDBAo5 qtKq/oUBu2yd6HfQjvFTnBb/jpQm1fOFfVY9nOjjkYIjEbSS8yZjsgUR/OlPuQuElDiS IZKEsCkV+A+DpsGh8911CWIapLIvAz3IW8FR4yo+C0SjdWcZugoOF85cnfeOG1Zh1Luk 33Qbhcti9p0OELVD/BYZw2H82kS05jxGGZ/zuvQgp0a9Wza1X6ugq92c+vT+z0PNHVtK YbDHSIGfWCbyquMzA37mLI87M6a54ANHbcadK9Tatc5f7U3qljnIm0GWvouAwwhRcARW VS0g== MIME-Version: 1.0 X-Received: by 10.180.92.138 with SMTP id cm10mr8139963wib.33.1442330810993; Tue, 15 Sep 2015 08:26:50 -0700 (PDT) Received: by 10.28.158.9 with HTTP; Tue, 15 Sep 2015 08:26:50 -0700 (PDT) In-Reply-To: References: Date: Tue, 15 Sep 2015 11:26:50 -0400 Message-ID: From: Jeff Garzik To: Btc Drak Content-Type: multipart/alternative; boundary=f46d043be24ea3519c051fcacf94 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham 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 15:26:54 -0000 --f46d043be24ea3519c051fcacf94 Content-Type: text/plain; charset=UTF-8 Drak, I would say that the refactoring does actually fulfill some conditions you mention: - move-only is almost always clearly separated out - the refactoring is not controversial _in minimis_ - meaning, the individual pull request is not controversial. The problem comes with the impact of an unfocused stream of refactors to key code. For example, there is much less long term developer impact if refactoring were _accelerated_, scheduled to be performed in a one-week sprint. There is a lot of breakage, yes, but after that week the average level of downstream patch breakage is significantly lower. A "rip the band-aid off quickly rather than slowly" approach. On Tue, Sep 15, 2015 at 5:55 AM, Btc Drak wrote: > 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 >> > > --f46d043be24ea3519c051fcacf94 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Drak,

I would say that the refactoring = does actually fulfill some conditions you mention:
- move-only is= almost always clearly separated out
- the refactoring is not con= troversial _in minimis_ - meaning, the individual pull request is not contr= oversial.

The problem comes with the impact of an = unfocused stream of refactors to key code.

For exa= mple, there is much less long term developer impact if refactoring were _ac= celerated_, scheduled to be performed in a one-week sprint.=C2=A0 There is = a lot of breakage, yes, but after that week the average level of downstream= patch breakage is significantly lower.=C2=A0 A "rip the band-aid off = quickly rather than slowly" approach.




On Tue, Sep 15, 2015 at 5:55 AM, Btc Drak <btcdrak@gmail.com>= ; wrote:
I a= lso share a lot of Jeff's concerns about refactoring and have voiced th= em 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 sta= ted the various problems. I would like to share my thoughts on the matter b= ecause 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 refacto= ring. However, it requires proper planning because there are lots of effect= s and consequences for other people contributing to Core and also downstrea= m projects relying on Core:=C2=A0

1. Refactoring o= ften 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. Ver= sion 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 har= d to follow release to release and the net result is less people upgrade (e= specially think of miners trying to keep their patch sets working while try= ing not to disrupt or risk their mining operations).

3. Continual refactoring increases risk: we're human, and mistakes w= ill 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.=C2=A0

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=
---------------------------------

W= ith the understanding that refactored code by definition must not change be= haviour. There are three major kinds of refactoring:=C2=A0
1. code moves (e.g. separating concerns into different files);=
2. code style;
3. structural optimisation and consolid= ation (reducing LOC, separating concerns, encapsulation etc).=C2=A0

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 t= he code changed, the behaviour (including any bugs) did not.
=
We must resist all temptation to fix bugs or tack on minor f= ixes and tweaks during refactoring: pull requests should only be refactorin= g only, with no net change to behaviour. Keeping discipline makes it much e= asier to verify and peer review and this faster to merge.

With respect to=C2=A0Code moves and CS,=C2=A0I believe we should ha= ve a "refactoring fortnight" where we so the bulk of code move-on= ly 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 d= ribs 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 t= hings in the future. The idea here is to help orientation and not have to c= ontinuously hunt for where things have moved to.

T= o 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.=C2=A0

With r= egards to CS, I think we do need to get CS right, because a continual dribb= le of CS changes also makes diffs between releases less easy to follow. Muc= h 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 need= s 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.=C2=A0

Obviously the third kind of refactoring more complex and = time consuming and will need to occur over time, but it should happen in de= fined 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.=C2=A0

Finally, refactoring should *always* be uncontroversial because essentiall= y 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 straightf= orward.=C2=A0



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 g= ithub 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


--f46d043be24ea3519c051fcacf94--