git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Derrick Stolee <stolee@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 01/19] revision.h: avoid bit fields in struct rev_info
Date: Thu, 9 May 2019 16:56:27 +0700	[thread overview]
Message-ID: <CACsJy8BR9XqEvQfnaBAjdgtp6J=FOhbUDpYCkMN4P4wOcw5Dmg@mail.gmail.com> (raw)
In-Reply-To: <d018ea8c-6f7f-1587-d56b-af3225d6cf0b@gmail.com>

On Wed, May 8, 2019 at 10:52 PM Derrick Stolee <stolee@gmail.com> wrote:
>
> On 5/8/2019 10:41 AM, Duy Nguyen wrote:
> > On Wed, May 8, 2019 at 9:07 PM Derrick Stolee <stolee@gmail.com> wrote:
> >>
> >> On 5/8/2019 7:12 AM, Nguyễn Thái Ngọc Duy wrote:
> >>> Bitfield addresses cannot be passed around in a pointer. This makes it
> >>> hard to use parse-options to set/unset them. Turn this struct to
> >>> normal integers. This of course increases the size of this struct
> >>> multiple times, but since we only have a handful of rev_info variables
> >>> around, memory consumption is not at all a concern.
> >>
> >> I think you are right that this memory trade-off shouldn't be a problem.
> >>
> >> What worries me instead is that we are using an "internal" data structure
> >> for option parsing. Would it make more sense to create a struct for use
> >> in the parse_opts method and a method that translates those options into
> >> the bitfield in struct rev_info?
> >
> > But we are doing that now (option parsing) using the same data
> > structure. Why would changing from a custom parser to parse_options()
> > affect what fields it should or should not touch in rev_info? Genuine
> > question. Maybe you could elaborate more about "internal". I probably
> > missed something. Or maybe this is a good opportunity to separate
> > intermediate option parsing variables from the rest of rev_info?
>
> You're right. I was unclear.
>
> rev_info stores a lot of data. Some of the fields are important
> in-memory structures that are crucial to the workings of revision.c
> and are never used by builtin/rev-list.c. Combining this purpose
> with the option parsing seems smelly to me.
>
> Thinking more on it, I would prefer a more invasive change that may
> pay off in the long term. These options, along with the "starting list"
> values, could be extracted to a 'struct rev_options' that contains these
> integers and the commit list. Then your option parsing changes could be
> limited to a rev_options struct, which is later inserted into a rev_info
> struct during setup_revisions().
>
> Generally, the rev_info struct has too many members and could be split
> into smaller pieces according to purpose. I created the topo_walk_info
> struct as a way to not make the situation worse, but doesn't fix existing
> pain.
>
> My ramblings are mostly complaining about old code that grew organically
> across many many quality additions. It is definitely hard to understand
> the revision-walking code, and perhaps it would be easier to understand
> with a little more structure.

Thanks. This is much better.

> The biggest issue with my suggestion is that it requires changing the
> consumers of the options, as they would no longer live directly on the
> rev_info struct. That would be a big change, even if it could be done
> with string replacement.

I agree rev_info has grown "wild". It's quite ancient code. As you
noted, it's a big change. And since my series is already long (76
patches), I would rather focus on just one thing, rewriting the
parsing code with minimum changes to anything else, preferably retain
the exact same old behavior.

After that work is done (and no regression found), we could focus on
reorganizing rev_info, which could be quite "interesting". Some fields
may be overloaded with different purposes, which I just can't spend
time investigating now. There's also the problem with freeing
resources after rev-list is done, which I think we have ignored so
far.
-- 
Duy

  reply	other threads:[~2019-05-09  9:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 11:12 [PATCH 00/19] Convert revision.c to parseopt part 1/4 Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 01/19] revision.h: avoid bit fields in struct rev_info Nguyễn Thái Ngọc Duy
2019-05-08 14:07   ` Derrick Stolee
2019-05-08 14:41     ` Duy Nguyen
2019-05-08 15:52       ` Derrick Stolee
2019-05-09  9:56         ` Duy Nguyen [this message]
2019-05-09 12:11           ` Derrick Stolee
2019-05-08 11:12 ` [PATCH 02/19] revision.h: move repo field down Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 03/19] revision.c: prepare to convert handle_revision_pseudo_opt() Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 04/19] rev-parseopt: convert --all Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 05/19] rev-parseopt: convert --branches Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 06/19] rev-parseopt: convert --bisect Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 07/19] rev-parseopt: convert --tags Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 08/19] rev-parseopt: convert --remotes Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 09/19] rev-parseopt: convert --glob Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 10/19] rev-parseopt: convert --exclude Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 11/19] rev-parseopt: convert --reflog Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 12/19] rev-parseopt: convert --indexed-objects Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 13/19] rev-parseopt: convert --not Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 14/19] rev-parseopt: convert --no-walk and --do-walk Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 15/19] rev-parseopt: convert --single-worktree Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 16/19] rev-parseopt: prepare to convert handle_revision_opt() Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 17/19] rev-parseopt: convert --max-count Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 18/19] rev-parseopt: convert --skip Nguyễn Thái Ngọc Duy
2019-05-08 11:12 ` [PATCH 19/19] rev-parseopt: convert --min-age and --max-age Nguyễn Thái Ngọc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACsJy8BR9XqEvQfnaBAjdgtp6J=FOhbUDpYCkMN4P4wOcw5Dmg@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=stolee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).