General TC > Programming & Scripting - Unofficial
Tinkering with rebuildfstab
Rich:
Hi curaga
Thanks, I think you're right. I changed the shebang to bash and it runs:
--- Code: ---tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.git
real 0m 0.92s
user 0m 0.14s
sys 0m 0.32s
tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.git
real 0m 0.69s
user 0m 0.11s
sys 0m 0.36s
tc@E310:~/rebuildfstab$
--- End code ---
Rich:
Hi CNK
I changed how information is gathered but kept what is done with
it basically the same.
For each test, I cleared the cache, then ran the script 3 times in succession.
Timing on Dell E310 desktop TC10 x86
Original rebuildfstab from TC10:
--- Code: ---tc@E310:~/rebuildfstab$ time sudo rebuildfstab
real 0m 1.98s
user 0m 0.37s
sys 0m 0.83s
tc@E310:~/rebuildfstab$ time sudo rebuildfstab
real 0m 1.42s
user 0m 0.36s
sys 0m 0.83s
tc@E310:~/rebuildfstab$ time sudo rebuildfstab
real 0m 1.41s
user 0m 0.40s
sys 0m 0.76s
--- End code ---
rebuildfstab from git, shebang changed to bash so it would run under TC10:
--- Code: ---tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.git
real 0m 1.05s
user 0m 0.17s
sys 0m 0.54s
tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.git
real 0m 0.78s
user 0m 0.15s
sys 0m 0.39s
tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.git
real 0m 0.71s
user 0m 0.12s
sys 0m 0.39s
--- End code ---
My version of rebuildfstab:
--- Code: ---tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.rewrite
real 0m 0.72s
user 0m 0.06s
sys 0m 0.12s
tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.rewrite
real 0m 0.16s
user 0m 0.09s
sys 0m 0.06s
tc@E310:~/rebuildfstab$ time sudo ./rebuildfstab.rewrite
real 0m 0.23s
user 0m 0.07s
sys 0m 0.11s
--- End code ---
I've done testing on 2 desktops (TC9 x86 and TC10 x86) and 1 laptop (TC14.0alpha1 x86_64)
and can no longer find any issues.
Timing on the laptop
rebuildfstab from TC14.0alpha1:
--- Code: ---tc@box:~$ time sudo ./rebuildfstab
real 0m 0.36s
user 0m 0.06s
sys 0m 0.14s
tc@box:~$ time sudo ./rebuildfstab
real 0m 0.27s
user 0m 0.05s
sys 0m 0.11s
tc@box:~$ time sudo ./rebuildfstab
real 0m 0.31s
user 0m 0.05s
sys 0m 0.12s
--- End code ---
My version of rebuildfstab:
--- Code: ---tc@box:~$ time sudo ./rebuildfstab.rewrite
real 0m 0.14s
user 0m 0.04s
sys 0m 0.06s
tc@box:~$ time sudo ./rebuildfstab.rewrite
real 0m 0.13s
user 0m 0.04s
sys 0m 0.05s
tc@box:~$ time sudo ./rebuildfstab.rewrite
real 0m 0.09s
user 0m 0.04s
sys 0m 0.04s
--- End code ---
I've attached a copy for you and any other interested parties to
test, examine the code, and provide feedback.
For those that feel code is self commenting, you can remove most of them like this:
--- Code: ---tc@E310:~/rebuildfstab$ grep -v "### " rebuildfstab.rewrite > rebuildfstab.stripped
tc@E310:~/rebuildfstab$ ls -l rebuildfstab.git rebuildfstab.rewrite rebuildfstab.stripped
-rwxr-xr-x 1 tc staff 2595 Feb 27 08:56 rebuildfstab.git
-rwxr-xr-x 1 tc staff 4145 Mar 5 10:13 rebuildfstab.rewrite
-rw-r--r-- 1 tc staff 2735 Mar 5 12:33 rebuildfstab.stripped
tc@E310:~/rebuildfstab$
--- End code ---
CNK:
Nice work, it's the fastest yet on the first PC I've tested it on (TC 13, x86_64). It does query blkid multiple times, which as Curaga pointed out earlier is avoided in the current Git-repo code, although the "blkid -s TYPE" command that the current script uses actually takes longer to complete on its own than your whole script does in my tests. Maybe that's because that PC only has six hardware block devices present though.
Also I notice that you didn't add ext4 to the part where "relatime" gets added to the mount options for ext file systems (line 135). I see that the script in the Git repo doesn't do that at all though, and I see that the mount man page says "relatime" is now the default, so that line can probably be removed from your script too.
I'll test it out in TC 13 on another x86_64 PC later. Maybe sometime I'll try it on my 100MHz i486 laptop too and see how many hours it takes. :)
curaga:
This version also misses custom mounts, and I feel the queue logic is worse than the current checks. If two more scripts happen to be spawned while one is running, the old version would only rerun once, this would rerun them all.
Regarding comments, some additions are definitely welcome, like the 98 block major etc. Though some new ones are overboard IMHO.
I'd prefer a minimal patch just replacing the find line and editing the awk script correspondingly (and a few comments). Otherwise adding custom mounts and running blkid just once to your version may need multiple grep calls, etc.
Rich:
Hi curaga
--- Quote from: curaga on March 06, 2023, 02:31:22 AM ---This version also misses custom mounts, ...
--- End quote ---
Could you provide a detailed example of what gets missed please.
--- Quote --- ... and I feel the queue logic is worse than the current checks. If two more scripts happen to be spawned while one is running, the old version would only rerun once, this would rerun them all. ...
--- End quote ---
Exactly. A program calling rebuildfstab expects to find an updated fstab.
Consider 2 programs calling at the same time:
| ProgramA | rebuildfstab scans devices, updates fstab, launches rebuildfstab again | ProgramA reads fstab |
| ProgramB | rebuildfstab touches rescan file and exits | ProgramB reads fstab |
ProgramA is blocked until rebuildfstab updates fstab.
ProgramB is allowed to continue, unaware that rebuildfstab did not run for it.
While I don't expect this type of situation to happen often I felt it was a
better way of handling it.
--- Quote --- ... Otherwise adding custom mounts and running blkid just once ...
--- End quote ---
I'll take a closer look at that.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version