Hi,

thanks for the answers.

On 2023-11-28 01:51:46 +0100, Maxime Devos wrote:
> (set! copy-file improved-copy-file)
> 
> This replacement 100% functioning assumes no inlining, nobody capturing the
> old copy-file on the top-level, nobody calling the C function directly ...

In that case this is what I will use.  There should be no fundamental problem if
some case will be missed, since I am doing performance optimization only,
correctness is not affected.

> 
> If the original copy-file is implemented in Scheme, then to avoid inlining
> problems, the module defining copy-file should do
> 
> (set! copy-file copy-file).

It looks like it is defined inside libguile/filesys.c, so that is not an option.
And I would like to avoid patching the Guile itself anyway.

> 
> That way, Guile's compiler/optimizer knows that the binding is mutable and
> should not inlined (well, Guile being Guile, every binding is mutable, but
> now it is mutable from the perspective of the inliner too).

Interesting, is there a way to do the same hint from the C code?  Would there be
a reason?  I assume C code cannot be inlined anyway, so there is no need?

> 
> Depending on whether 'copy-file' is just a stand-in for something else and
> depending on how the better copy-file works/how it is ‘better’, it might be
> better to eventually write a patch to replace copy-file with the improved
> better-file, as then the improved copy-file is more widely available. (As a
> long-term thing; for short-term ‘trying things out’, doing set! is much more
> practical.)

What I want to do is to replace (copy-file oldfile newfile) by modified version
with signature (copy-file oldfile newfile [reflink]) with reflink defaulting to
'auto (see man cp for details).

I expect this to be a somewhat controversial change, so I did not intend to send
a patch, however I can, if you think it has a chance of getting merged.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

Attachment: signature.asc
Description: PGP signature

Reply via email to