Code Monkey home page Code Monkey logo

grub's People

Contributors

agraf avatar alecrbrown avatar arvidjaar avatar chrisccoulson avatar cjwatson avatar cpina avatar crass avatar darrenkenny avatar daxtens avatar elyesh avatar esnowberg avatar fezie avatar floppym avatar frozencemetery avatar gsutre avatar jgross1 avatar jwrdegoede avatar kreijack avatar martinezjavier avatar ozbenh avatar pfsmorigo avatar phcoder avatar pks-t avatar robertmillan avatar sthibaul avatar uudiin avatar vathpela avatar wenhuachang avatar xypron avatar zhangboyang avatar

Watchers

 avatar

grub's Issues

Poor performance of grub_file_open()

The fs detection is performed on every grub_file_open(), which is redundant and unnecessary:

grub-core/kern/disk.c:196:disk: Opening `loop0'...
grub-core/kern/fs.c:56:fs: Detecting zfs...
grub-core/fs/zfs/zfs.c:1199:zfs: label ok 0
grub-core/fs/zfs/zfs.c:1199:zfs: label ok 1
grub-core/fs/zfs/zfs.c:1199:zfs: label ok 2
grub-core/fs/zfs/zfs.c:1199:zfs: label ok 3
grub-core/kern/fs.c:79:fs: error: couldn't find a valid label.
grub-core/kern/fs.c:80:fs: zfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting xfs...
grub-core/fs/xfs.c:944:xfs: Reading sb
grub-core/fs/xfs.c:276:xfs: Validating superblock
grub-core/kern/fs.c:79:fs: error: not a XFS filesystem.
grub-core/kern/fs.c:80:fs: xfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting ufs2...
grub-core/kern/fs.c:79:fs: error: not an ufs2 filesystem.
grub-core/kern/fs.c:80:fs: ufs2 detection failed.
grub-core/kern/fs.c:56:fs: Detecting ufs1_be...
grub-core/kern/fs.c:79:fs: error: not an ufs1 filesystem.
grub-core/kern/fs.c:80:fs: ufs1_be detection failed.
grub-core/kern/fs.c:56:fs: Detecting ufs1...
grub-core/kern/fs.c:79:fs: error: not an ufs1 filesystem.
grub-core/kern/fs.c:80:fs: ufs1 detection failed.
grub-core/kern/fs.c:56:fs: Detecting udf...
grub-core/kern/fs.c:79:fs: error: not an UDF filesystem.
grub-core/kern/fs.c:80:fs: udf detection failed.
grub-core/kern/fs.c:56:fs: Detecting tarfs...
grub-core/kern/fs.c:79:fs: error: not a tarfs filesystem.
grub-core/kern/fs.c:80:fs: tarfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting squash4...
grub-core/kern/fs.c:79:fs: error: not squash4.
grub-core/kern/fs.c:80:fs: squash4 detection failed.
grub-core/kern/fs.c:56:fs: Detecting sfs...
grub-core/kern/fs.c:79:fs: error: not a SFS filesystem.
grub-core/kern/fs.c:80:fs: sfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting romfs...
grub-core/kern/fs.c:79:fs: error: too short filesystem.
grub-core/kern/fs.c:80:fs: romfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting reiserfs...
grub-core/kern/fs.c:79:fs: error: not a ReiserFS filesystem.
grub-core/kern/fs.c:80:fs: reiserfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting procfs...
grub-core/kern/fs.c:79:fs: error: not a procfs.
grub-core/kern/fs.c:80:fs: procfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting odc...
grub-core/kern/fs.c:79:fs: error: not a odc filesystem.
grub-core/kern/fs.c:80:fs: odc detection failed.
grub-core/kern/fs.c:56:fs: Detecting ntfs...
grub-core/kern/fs.c:79:fs: error: not an ntfs filesystem.
grub-core/kern/fs.c:80:fs: ntfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting nilfs2...
grub-core/kern/fs.c:79:fs: error: not a nilfs2 filesystem.
grub-core/kern/fs.c:80:fs: nilfs2 detection failed.
grub-core/kern/fs.c:56:fs: Detecting newc...
grub-core/kern/fs.c:79:fs: error: not a newc filesystem.
grub-core/kern/fs.c:80:fs: newc detection failed.
grub-core/kern/fs.c:56:fs: Detecting minix_be...
grub-core/kern/fs.c:79:fs: error: not a minix filesystem.
grub-core/kern/fs.c:80:fs: minix_be detection failed.
grub-core/kern/fs.c:56:fs: Detecting minix3_be...
grub-core/kern/fs.c:79:fs: error: not a minix3 filesystem.
grub-core/kern/fs.c:80:fs: minix3_be detection failed.
grub-core/kern/fs.c:56:fs: Detecting minix3...
grub-core/kern/fs.c:79:fs: error: not a minix3 filesystem.
grub-core/kern/fs.c:80:fs: minix3 detection failed.
grub-core/kern/fs.c:56:fs: Detecting minix2_be...
grub-core/kern/fs.c:79:fs: error: not a minix2 filesystem.
grub-core/kern/fs.c:80:fs: minix2_be detection failed.
grub-core/kern/fs.c:56:fs: Detecting minix2...
grub-core/kern/fs.c:79:fs: error: not a minix2 filesystem.
grub-core/kern/fs.c:80:fs: minix2 detection failed.
grub-core/kern/fs.c:56:fs: Detecting minix...
grub-core/kern/fs.c:79:fs: error: not a minix filesystem.
grub-core/kern/fs.c:80:fs: minix detection failed.
grub-core/kern/fs.c:56:fs: Detecting jfs...
grub-core/kern/fs.c:79:fs: error: not a JFS filesystem.
grub-core/kern/fs.c:80:fs: jfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting iso9660...
grub-core/kern/fs.c:79:fs: error: not a ISO9660 filesystem.
grub-core/kern/fs.c:80:fs: iso9660 detection failed.
grub-core/kern/fs.c:56:fs: Detecting hostfs...
grub-core/kern/fs.c:79:fs: error: not a hostfs.
grub-core/kern/fs.c:80:fs: hostfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting hfsplus...
grub-core/kern/fs.c:79:fs: error: not a HFS+ filesystem.
grub-core/kern/fs.c:80:fs: hfsplus detection failed.
grub-core/kern/fs.c:56:fs: Detecting hfs...
grub-core/kern/fs.c:79:fs: error: not an HFS filesystem.
grub-core/kern/fs.c:80:fs: hfs detection failed.
grub-core/kern/fs.c:56:fs: Detecting fat...
grub-core/kern/fs.c:79:fs: error: not a FAT filesystem.
grub-core/kern/fs.c:80:fs: fat detection failed.
grub-core/kern/fs.c:56:fs: Detecting f2fs...
grub-core/kern/fs.c:79:fs: error: not a F2FS filesystem (no superblock).
grub-core/kern/fs.c:80:fs: f2fs detection failed.
grub-core/kern/fs.c:56:fs: Detecting ext2...
grub-core/kern/disk.c:295:disk: Closing `loop0'.

This issue affects both grub-mount and native GRUB run time environment.

Steps to reproduce:

ls -l (drive_with_linux_installation)/usr/lib
ls -l (drive_with_linux_installation)/usr/lib64

Very poor performance of readdir in grub-mount

Very poor performance of readdir in grub-mount

Some numbers. An ext4 partition with Artix installation:

    ls /mnt/1/etc
        takes 0m0.620s to read 351 items
    ls /mnt/1/usr/share
        takes 0m0.965s to read 406 items
    ls /mnt/1/usr/share/applications
        takes 0m1.248s to read 209 items
    ls /mnt/1/usr/bin
        takes 7m9.744s to read 5725 items
    ls /mnt/1/usr/lib
        takes 7m47.797s to read 5202 items

One more ext4 partition with ROSA installation:

    ls /mnt/2/usr/lib64
        takes 1m26.409s to read 2202 items
    ls /mnt/2/usr/bin
        takes 0m10.028s to read 2982 items
    ls /mnt/2/usr/sbin
        takes 0m1.476s to read 525 items

7 minutes to scan usr/lib, which renders os-prober autodetection practically useless. It takes a half of hour to scan all partitions and detect OSes on my laptop.

Since the program is used in various installation scripts and package manager hooks, a reasonable performance is expected. Freezing for 30 minutes in an OS installation script is not an option.

The following old report may also be related to this issue: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760148

I made some investigations and here are my considerations:

1.

fuse_readdir_call_fill() is a callback function called on every direntry. fuse_readdir_call_fill() calls grub_file_open() in order to get file size and other stuff. grub_file_open() does the full path resolution, so it scans the same directory tree again to locate the file inode.

This makes the O()-complexity of the algorithm to be quadratic of the number of entries in the directory. Even worse, if an application calls getattr right next, getattr does same the path resolution one more time.

A separate issue which contributes to the total computational complexity is symlink resolution. A symlink can possibly trigger any number of directory rescans, and the total evaluation time is unpredictable.

The possible sollution: 0e5501d

2.

The fs rescan is performed on every grub_file_open(), which is redundant and unnecessary.

More details here: #2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.