raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com>
To: Eric Wong <e@80x24.org>
Cc: raindrops-public@yhbt.net
Subject: Re: [PATCH v2] Allow Raindrops objects to be backed by a file
Date: Mon, 29 Nov 2021 11:13:39 +1100	[thread overview]
Message-ID: <CAJ7wOOuK8bGeEgcr+-68ePWQ1r3fTxhBiJkYQfawQh7Q0iJecA@mail.gmail.com> (raw)
In-Reply-To: <20211126183400.GA9579@dcvr>

On Sat, Nov 27, 2021 at 5:34 AM Eric Wong <e@80x24.org> wrote:
>
> <snip>
>
> Note that applies to other projects, too: instead of a solid
> "-------" line, using a "----8<----" line as below
> (without indentation) for --scissors:
>
> <prose not intended for a git commit message>
>
> ----8<----
> Subject: [PATCH] Allow Raindrops objects to be backed by a file
>
> <rest of the commit message + patch...>
>
> The above allows maintainers to use `git am --scissors' to apply
> a patch while ignoring any text above the "----8<----" line.

Ah, today I learned, thanks for the tip.

> <snip>
>
> s/theat/that/ (I can squash this in on my end)

Uh, sorry about that. I could have sworn I did a pass looking for
typos. Apparently I missed a few.

> <snip>
> > - * Duplicates and snapshots the current state of a Raindrops object.
> > + * Duplicates and snapshots the current state of a Raindrops object. Even
> > + * if the given Raindrops object is backed by a file, the copy will be backed
> > + * by independent, anonymously mapped memory.
> > */
> > static VALUE init_copy(VALUE dest, VALUE source)
> > {
> > struct raindrops *dst = DATA_PTR(dest);
> > struct raindrops *src = get(source);
> >
> > - init(dest, SIZET2NUM(src->size));
> > + init_cimpl(dest, SIZET2NUM(src->size), Qnil, Qfalse);
> > memcpy(dst->drops, src->drops, raindrop_size * src->size);
>
> Switching from file-backed to anonymous seems strange to me,
> here, but I'm not sure of a better solution that's compatible
> with Object#dup ... I also don't know if anybody uses
> Raindrops#dup, either. So if you're satisfied with this
> behavior, that's good enough for me :>

I did wonder what I should do here. Could _also_ dup the file descriptor,
but then the raindrops will still share memory, which seems like the
opposite of what #dup should do. If someone wants to do something
different I guess the copy-constructor-ish initialize method could be
exposed for this purpose.

> Also, was there anything else you had planned? (e.g. for memfd)
> Otherwise, I'm thinking of tagging and releasing a new version
> in a week or so (at least before Ruby 3.1 on Dec 25)

Nope, this was it. Memfd is exactly equivalent to just using an
unlinked tempfile on tmpfs so doing it this way will suit our needs
nicely. If anybody else desperately wants to use memfd here I don't
think there's much more to it than

  IO.new syscall(319, "file_name", 0)

Syscall number is even the same on x86_64 and arm64 too!

Anyway, thanks again for your help with this, and thanks also for
bearing with my very rusty git email workflow :)

KJ


  reply	other threads:[~2021-11-29  0:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-25  6:56 KJ Tsanaktsidis
2021-11-26 18:34 ` Eric Wong
2021-11-29  0:13   ` KJ Tsanaktsidis [this message]
2021-11-30  6:49     ` Eric Wong

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: https://yhbt.net/raindrops/

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

  git send-email \
    --in-reply-to=CAJ7wOOuK8bGeEgcr+-68ePWQ1r3fTxhBiJkYQfawQh7Q0iJecA@mail.gmail.com \
    --to=ktsanaktsidis@zendesk.com \
    --cc=e@80x24.org \
    --cc=raindrops-public@yhbt.net \
    --subject='Re: [PATCH v2] Allow Raindrops objects to be backed by a file' \
    /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

Code repositories for project(s) associated with this inbox:

	../../raindrops.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).