public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Patrick O'Neill <patrick@rivosinc.com>
To: Palmer Dabbelt <palmer@dabbelt.com>, binutils@sourceware.org
Cc: Kito Cheng <kito.cheng@gmail.com>, gnu-toolchain@rivosinc.com
Subject: Re: [PATCH 0/4] RISCV: Improve linker time complexity
Date: Mon, 25 Apr 2022 10:26:32 -0700	[thread overview]
Message-ID: <f6a05fa9-9e6b-5b0b-9db3-b7c2ac3d9f29@rivosinc.com> (raw)
In-Reply-To: <mhng-c402eb04-240a-4f39-9868-54b1b8102391@palmer-ri-x1c9>

On 4/13/22 11:11, Palmer Dabbelt wrote:
> On Tue, 12 Apr 2022 22:12:22 PDT (-0700), binutils@sourceware.org wrote:
>> On Wed, Apr 13, 2022 at 08:58:38AM +0800, Kito Cheng via Binutils wrote:
>>> And I have a suggestion here is - does it possible to let co-exist 
>>> with current
>>> implementation and having a command line option to select the linker
>>> relaxation, of course we
>>> could default to using the new implementation, but that gives us an
>>> emergency fallback option to use the old implementation :)
>>
>> You already have an emergency fallback, use an older binutils or
>> revert the patchset.  IMO you do not want two implementations of any
>> given feature.   Doing so just makes it more likely that neither
>> implementation is good.
>
> IMO a key point here is that the hueristics are subtly different, the 
> linear-time algorithm will fail at both forwards and backwards targets 
> where relaxation enables relaxation (as opposed to just failing at the 
> forwards targets, like the old one did).  The theory is that there 
> aren't any pathological cases in the wild, but it's hard to know for 
> sure.  I think it should just be a few lines of code to match the old 
> behavior (ie, just eagerly delete instead of deferring it to after all 
> relocations are processed), but I'm not sure -- the change around 
> alignment handling is tripping me up, as that was unexpected on my end.
>
> That said, there's certainly enough complexity here so I don't think 
> it's a big deal to just only support the new flavor.

If we're only concerned about the backwards targets then it should be
relatively easy to have it evaluate the relaxation deletions
immediately.

There's a challenge in that the current method expects all deletions to
occur one after another with a running tally of deleted bytes. This
causes issues when a deletion depends on a later deletion to clear up
any slack introduced. To solve this, I think it'd be 2 if statements.
One to delete immediately, and one to not depend on a running tally when
deleting immediately.

Regarding the change to alignment/reordered passes, those changes just
defer the deletions related to alignment to one pass at the end. Other
than concerns around correctness, I don't see a reason to keep the old
flavor of alignment around. The old flavor has O(n^2) time complexity
and doesn't change the underlying behavior.

  reply	other threads:[~2022-04-25 17:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 16:25 Patrick O'Neill
2022-04-12 16:25 ` [PATCH 1/4] RISCV: Add linker relaxation tests Patrick O'Neill
2022-04-12 16:25 ` [PATCH 2/4] RISCV: Arrange DELETE pass after .align pass Patrick O'Neill
2022-04-12 16:26 ` [PATCH 3/4] RISCV: Implement piecewise deletion Patrick O'Neill
2022-04-12 16:26 ` [PATCH 4/4] RISCV: Improve runtime of align directives Patrick O'Neill
2022-04-13  0:58 ` [PATCH 0/4] RISCV: Improve linker time complexity Kito Cheng
2022-04-13  2:23   ` Palmer Dabbelt
2022-04-13  5:12   ` Alan Modra
2022-04-13 18:11     ` Palmer Dabbelt
2022-04-25 17:26       ` Patrick O'Neill [this message]
2022-05-02 13:50 ` [PATCH v2 0/5] " Patrick O'Neill
2022-05-02 13:50   ` [PATCH v2 1/5] RISCV: Add linker relaxation tests Patrick O'Neill
2022-05-02 13:50   ` [PATCH v2 2/5] RISCV: Arrange DELETE pass after .align pass Patrick O'Neill
2022-05-02 13:50   ` [PATCH v2 3/5] RISCV: Implement piecewise deletion Patrick O'Neill
2022-05-20 10:48     ` Nelson Chu
2022-05-20 17:36       ` Patrick O'Neill
2022-05-02 13:50   ` [PATCH v2 4/5] RISCV: Improve runtime of align directives Patrick O'Neill
2022-05-02 13:50   ` [PATCH v2 5/5] RISCV: Add --defer-deletion flag Patrick O'Neill
2022-05-27 21:20   ` [PATCH v3 0/3] RISCV: Improve linker time complexity Patrick O'Neill
2022-05-27 21:20     ` [PATCH v3 1/3] RISCV: Add linker relaxation tests Patrick O'Neill
2022-05-27 21:20     ` [PATCH v3 2/3] RISCV: Implement piecewise deletion Patrick O'Neill
2022-05-27 21:20     ` [PATCH v3 3/3] RISCV: Add --defer-deletion flag Patrick O'Neill

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=f6a05fa9-9e6b-5b0b-9db3-b7c2ac3d9f29@rivosinc.com \
    --to=patrick@rivosinc.com \
    --cc=binutils@sourceware.org \
    --cc=gnu-toolchain@rivosinc.com \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@dabbelt.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.
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).