Why is GRUB taking so long to load my kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
justin
Member
Member
Posts: 43
Joined: Sun Jan 11, 2009 2:09 pm

Why is GRUB taking so long to load my kernel

Post by justin »

It takes 1 min 4 sec in bochs and 11 sec in qemu. Time in bochs is going about 10% faster than real time.

My kernel is about 250k and is being loaded from a hard disk. No surprises in grub.cfg:

Code: Select all

   multiboot /boot/kernel.elf
   boot
Any ideas?

Thanks.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Why is GRUB taking so long to load my kernel

Post by sortie »

Perhaps try enable kvm using -enable-kvm if you have it available?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Why is GRUB taking so long to load my kernel

Post by Combuster »

I wouldn't just blame bochs/qemu or grub, I have seen them both boot OSes over an MB in size in less than 5 seconds. That basically leaves two options:

- You're using your tools wrong (and I don't think KVM is the fix since I've done without it for long enough)
- You're not measuring properly. In other words you're not actually measuring from the time you hit enter in grub until the first instruction in your kernel is executed. Since GRUB doesn't visibly show you exactly that moment, your kernel has to do it, and your kernel might decide to do a ton of other stuff first.


Also, 250k for a starter(?) kernel sounds like a lot. Mine is a mere 15k in comparison and runs an entire userspace just fine. That may also be a hint to your problem
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
justin
Member
Member
Posts: 43
Joined: Sun Jan 11, 2009 2:09 pm

Re: Why is GRUB taking so long to load my kernel

Post by justin »

sortie wrote:Perhaps try enable kvm using -enable-kvm if you have it available?
Thanks. Will give it a shot.
Combuster wrote:I wouldn't just blame bochs/qemu or grub, I have seen them both boot OSes over an MB in size in less than 5 seconds. That basically leaves two options:

- You're using your tools wrong (and I don't think KVM is the fix since I've done without it for long enough)
- You're not measuring properly. In other words you're not actually measuring from the time you hit enter in grub until the first instruction in your kernel is executed. Since GRUB doesn't visibly show you exactly that moment, your kernel has to do it, and your kernel might decide to do a ton of other stuff first.


Also, 250k for a starter(?) kernel sounds like a lot. Mine is a mere 15k in comparison and runs an entire userspace just fine. That may also be a hint to your problem
-Could you elaborate on what you mean by using my tools wrong?

-I have tried making the timeout nonzero and have discovered that the lag is entirely prior to the GRUB menu coming, so I'm confident it is something that GRUB is doing, not the kernel.


I have since found that other people are having this problem as well on real hardware with GRUB2:
http://lists.debian.org/debian-user/201 ... 00737.html

I tried setting translation=lba for my disk in bochsrc but that didn't help.
justin
Member
Member
Posts: 43
Joined: Sun Jan 11, 2009 2:09 pm

Re: Why is GRUB taking so long to load my kernel

Post by justin »

Combuster wrote:Also, 250k for a starter(?) kernel sounds like a lot. Mine is a mere 15k in comparison and runs an entire userspace just fine. That may also be a hint to your problem
I investigated your advice, but I don't think size is the problem. I ran strip on my kernel and it's down to 88k (still large, but ~1/3 the prior size) and GRUB took 1 min 7 sec in bochs. Compare to 1 min 4 sec with the old file.

Of course, the discarded parts aren't loaded anyways, but I don't think 88k should take 1 minute to read off the disk.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Why is GRUB taking so long to load my kernel

Post by sortie »

Mind you that bochs is significantly slower than real hardware. You will need to adjust the instructions-per-seconds accordingly to how fast it runs on your computer. But, it's probably not worth thinking too much about how fast bochs runs, just whether it runs correctly.
Post Reply