From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS30031 170.10.132.0/23 X-Spam-Status: No, score=-4.6 required=3.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from us-smtp-delivery-110.mimecast.com (us-smtp-delivery-110.mimecast.com [170.10.133.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C5A321F953 for ; Mon, 29 Nov 2021 00:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zendesk.com; s=mimecast20150210; t=1638144833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I2LD0Oehbd1547eQ47EHd8WR6h12GRhmY1sluK1Chr4=; b=QmiG8a7T5m7BNPxLwKQiV/IyTz/aCtbs/vOxRlZWTQ8UlwERpG3H9EIUEX/MtH0pQqqs66 5zu/+XY+HLO292TjHUHkqH3K2YoI2x1iw/0nEgieGzgKxpZMXyohnF5ERt/tUhRQeo+HIE 8ocKaQSuWRgd6M1d/FCQGV/tooiJ93E= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-306-RElZwzSpOmKUpYJiLBc5Zw-1; Sun, 28 Nov 2021 19:13:52 -0500 X-MC-Unique: RElZwzSpOmKUpYJiLBc5Zw-1 Received: by mail-pg1-f200.google.com with SMTP id r15-20020a63ec4f000000b002e582189837so7454036pgj.20 for ; Sun, 28 Nov 2021 16:13:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RWk+Jly6Mstg0HxwdQMv12B9IuQdXLh4BII0xd0c0hU=; b=IQZfiJ/PFTH4nxmU0FGiq6AJCFvBJK962QKHJz6sHXdeyQmwWLBBGQE+sgeVdidRhq MTuErwd0X1RWS0XG06R1/kcl4yEojSv01SaBc43HdpcUmY8Z6g9QmoT4+MAm+nYgtntn A4HpKVK3RFkcwICDWgMF1GnO0Pj3ynrjYn8XscWhe5zl62Fl67XD+SiSGIFxCOnlv5o9 6tNG7ICkJHUg0QRnUeXGO6M9xEVCz1dgN7Ua74aW7IK/c5Sy/xMdy5wAmX0WVNtOpcb5 rPB1BwWFb5+UD/LfJzQTDYoqbPkOsrYI7PAAJ19W7h4n2FvDms6B9WufNvOK4qvclw4O sgQA== X-Gm-Message-State: AOAM532opbHvXbRrcj1ka07envbVdnNup6y7qmJ1yTXDICeZssUxhr3C DNJm62v0Df5sWINqBxXDUTLQHLBQmMvG+g7xgLJVWkLJp5YJ0hD1MmMhCpraWrDD91TVV3a05SP DqYAl9vCd/p11LazAE+2TVraFxhmbz2+xacI= X-Received: by 2002:a17:90b:1d0f:: with SMTP id on15mr34076998pjb.144.1638144830836; Sun, 28 Nov 2021 16:13:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBv6jDJIUOdqzvVOPb1oeZtB9TRhsWRW/0tDW9vd/yKv1h1rhVRBZtU+Gn9BsBCk8dEwK4/TuAiMMf29UJIk4= X-Received: by 2002:a17:90b:1d0f:: with SMTP id on15mr34076959pjb.144.1638144830366; Sun, 28 Nov 2021 16:13:50 -0800 (PST) MIME-Version: 1.0 References: <20211125065618.3432-1-ktsanaktsidis@zendesk.com> <20211126183400.GA9579@dcvr> In-Reply-To: <20211126183400.GA9579@dcvr> From: KJ Tsanaktsidis Date: Mon, 29 Nov 2021 11:13:39 +1100 Message-ID: Subject: Re: [PATCH v2] Allow Raindrops objects to be backed by a file To: Eric Wong Cc: raindrops-public@yhbt.net Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA10A63 smtp.mailfrom=ktsanaktsidis@zendesk.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: zendesk.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: On Sat, Nov 27, 2021 at 5:34 AM Eric Wong wrote: > > > > Note that applies to other projects, too: instead of a solid > "-------" line, using a "----8<----" line as below > (without indentation) for --scissors: > > > > ----8<---- > Subject: [PATCH] Allow Raindrops objects to be backed by a file > > > > 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. > > > 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. > > > - * Duplicates and snapshots the current state of a Raindrops object. > > + * Duplicates and snapshots the current state of a Raindrops object. E= ven > > + * 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 =3D DATA_PTR(dest); > > struct raindrops *src =3D 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