Skip to content

[feature/question] Enable kernel cache buffers #5643

Open

Description

@aalexgabi

In general when reading files kernel keeps files cached in memory buffers.

When reading a regular file twice, the second read is from memory which is very fast:

$ # Drop memory cache
$ free && sync && echo 3 | sudo tee /proc/sys/vm/drop_caches && free
$ dd if=1GiB bs=1M > /dev/null
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 4.18783 s, 256 MB/s
$ dd if=1GiB bs=1M > /dev/null
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.193063 s, 5.6 GB/s

How to enable this with rclone mount? Or is this a feature that is not supported?

Currently I get same read speed if I read a file twice:

$ dd if=1GiB bs=1M > /dev/null
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.86952 s, 277 MB/s
$ dd if=1GiB bs=1M > /dev/null
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.86199 s, 278 MB/s

I have mounted a GCS bucket without any additional arguments:

rclone mount gcs:<bucket-name> <mount-path>

Activity

  1. ncw commented on Oct 1, 2021

    @ncw
    Member

    Using an rclone I compiled locally with make GOTAGS=cmount

    I can do

    rclone cmount -vv s3:bucket -o auto_cache /mnt/tmp/
    

    Then I get this

    $ pv </mnt/tmp/file >/dev/null
     108KiB 0:00:00 [ 896KiB/s] [==============================================================================================================================================>] 100%            
    $ pv </mnt/tmp/file >/dev/null
     108KiB 0:00:00 [ 305MiB/s] [==============================================================================================================================================>] 100%            
    

    I don't think auto_cache is supported by the bazil fuse library (the one that powers rclone mount).

    from the fuse man page

       auto_cache
              This option enables automatic flushing  of  the  data  cache  on
              open(2). The cache will only be flushed if the modification time
              or the size of the file has changed.
    

    the alternative is kernel_cache which I think is too agressive

       kernel_cache
              This option disables flushing the cache of the file contents  on
              every  open(2).   This  should  only  be enabled on filesystems,
              where the file data is never changed externally (not through the
              mounted  FUSE  filesystem).  Thus it is not suitable for network
              filesystems and other intermediate filesystems.
    
              NOTE: if this option is not specified  (and  neither  direct_io)
              data is still cached after the open(2), so a read(2) system call
              will not always initiate a read operation.
    
  2. ivandeex commented on Oct 21, 2021

    @ivandeex
    Member

    this needs rclone with cmount (cgo based) baked in. we have a ticket #5090 targeted at producing cgo based rclone package for linux. you can implement it... or stay tuned :)

  3. ivandeex commented on Oct 28, 2021

    @ivandeex
    Member

    Promoting to documentation enhancement request connected with #5090

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions