qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Leonid Bloch <lbloch@janustech.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "Alberto Garcia" <berto@igalia.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/1] include: Auto-generate the sizes lookup table
Date: Thu, 3 Jan 2019 15:42:30 -0600	[thread overview]
Message-ID: <3797d82c-a6a6-eb97-be0c-67316ee55e22@redhat.com> (raw)
In-Reply-To: <472c0a97-283b-ac81-c07d-11843edd2488@janustech.com>

[-- Attachment #1: Type: text/plain, Size: 3786 bytes --]

On 1/3/19 3:21 PM, Leonid Bloch wrote:
> Hi,
> 
> On 1/4/19 12:04 AM, Eric Blake wrote:
>> On 1/3/19 2:57 PM, Leonid Bloch wrote:
>>
>>>> I have to say that I'm not very convinced of the benefits of replacing a
>>>> set of trivial numeric macros with a longer and harder to read shell
>>>> script accompanied by changes to the build system.
>>>
>>> I think that the benefit is that the script is easily verifiable,
>>> whereas if someone would like to verify the table, they will need to
>>> generate it themselves. Also, this table is automatically generated
>>> anyway, so it only makes sense to generate it during the build.
>>
>> But no one is submitting patches to active modify the table.  The work
>> has already been done once to generate it, and the reviewers have
>> already verified it; at this point, no further changes are likely to
>> happen (other than my pipe dream of entirely getting rid of the table in
>> favor of using runtime generation of human-friendly default strings is
>> added to QemuOpts instead).  If the table were not already in git, then
>> generating it at build time might make sense; but at this stage in the
>> game, you're slowing down every build to regenerate something that is
>> already correct.
>>
> 
> OK, that's a good point. But still, I think that you agree that it would 
> be more correct to generate it during the build, right? So now it is 
> there already and it works. But isn't it worth it to make it more correct?

I said "might make sense", not "I would have done it that way".  I also
don't see how a generated table is "more correct" than a hand-written
one - they are both equally correct if all values in the table match
what they are documented to provide.

In my view, code generators make sense when used on code that is
expected to change over time (a good example is QAPI because we add new
commands every release; other places might be a generator to help deal
with syscall handlers since newer kernels can add a syscall; or even the
fact that we have used some powerful GNU make textual processing to make
it easy to add files to particular subsets of the build with as few
lines edited as possible), where the goal is that the generator gives
you both a compact representation that is easier to edit, and that the
expansion from the generator ensures that repetitive boilerplate is
formed without typos.  In short, if a generator results in a net
reduction in lines of edited source in relation to the lines it
produces, AND if the source that gets regenerated is likely to change,
then it makes total sense to spend time on the generator.  But when the
amount of effort to write a generator costs as much as just hard-coding
the list outright, especially when the list is not going to change
(there really aren't any other powers of 2 within 64 bits), I'm not sure
a generator adds any value.  Unfortunately, your patch diffstat of:

>  .gitignore           |  1 +
>  Makefile             |  5 +++
>  block/qcow2.h        |  2 +-
>  block/vdi.c          |  1 +
>  include/qemu/units.h | 73 --------------------------------------------
>  scripts/gen-sizes.sh | 66 +++++++++++++++++++++++++++++++++++++++
>  6 files changed, 74 insertions(+), 74 deletions(-)
>  create mode 100755 scripts/gen-sizes.sh

is a wash (you did not result in any fewer lines in the codebase
overall), and the commit message did not do a good job saying WHY we
need it (you said WHAT it does - avoiding a hard-coded list - but not
WHY the hardcoded list is so bad that a generator would be better).  So
I'm not seeing the point of this patch.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-01-03 21:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02 11:08 [Qemu-devel] [PATCH 0/1] include: Auto-generate the sizes lookup table Leonid Bloch
2019-01-02 11:09 ` [Qemu-devel] [PATCH 1/1] " Leonid Bloch
2019-01-03  9:19   ` Alberto Garcia
2019-01-03 20:57     ` Leonid Bloch
2019-01-03 21:04       ` Eric Blake
2019-01-03 21:21         ` Leonid Bloch
2019-01-03 21:42           ` Eric Blake [this message]
2019-01-04  9:31             ` Alberto Garcia
2019-01-04 21:23               ` Leonid Bloch
2019-01-03  9:33   ` Philippe Mathieu-Daudé
2019-01-03 21:06     ` Leonid Bloch

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

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

  git send-email \
    --in-reply-to=3797d82c-a6a6-eb97-be0c-67316ee55e22@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=lbloch@janustech.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /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.
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 NNTP newsgroup(s).