Re: sysctl way too slow
Atom Smasher writes: > http://smasher.org/tmp/zsh-bsd-sysctl-slow.png > > is there a way to get this information that doesn't take so long? If you only need sysctl values for fancy prompt then cache them inside variables, e.g. PROMPT='($hw_acpi_battery_life, $hw_acpi_battery_time, $hw_acpi_battery_state) %# ' PERIOD=30 setopt promptsubst periodic_functions+=(sysctl-to-var) sysctl-to-var() { set -- hw.acpi.battery. for i in $(sysctl -N $@); do eval ${i:gs/./_/:gs/%//}='$(sysctl -n $i)' done } To not pollute global scope using one associative array for sysctls may be better. > > the same info is available on linux via /sys and /proc and on > comparable hardware, i can get the info about 100x faster. > > thanks... ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
On Wed, 14 Jul 2010, Ed Schouten wrote: So what about other sysctls? Is it just these sysctls? It may be the case that these values are not simply read from some variable in the kernel, but really performs some hardware calls. Still, 436 msec is quite a lot of time. === getting the same info on a linux box from /sys/class/power_supply/BAT0/* takes <10ms, even when reading all 32 files in the directory. meanwhile, on freebsd, the other hw.acpi.* variables i've tried are either reasonably fast (2-7 mS) or as slow, but no slower. at least not the handful that i've tried. hw.acpi.battery.* are the ones i'm actually interested in. -- ...atom http://atom.smasher.org/ 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808 - "About all you can do in life is be who you are. Some people will love you for you. Most will love you for what you can do for them, and some won't like you at all." -- Rita Mae Brown ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
On Wed, Jul 14, 2010 at 10:08 AM, Atom Smasher wrote: > On Wed, 14 Jul 2010, Joerg Sonnenberger wrote: > > On Wed, Jul 14, 2010 at 11:49:07PM +1200, Atom Smasher wrote: >> >>> the same info is available on linux via /sys and /proc and on comparable >>> hardware, i can get the info about 100x faster. >>> >> >> Are you sure that Linux is not just caching the data? I know of at least >> one system where it takes more than 100ms to query the battery state due to >> extremely slow hardware, I wouldn't be surprised if you can do worse. >> > == > > i don't know if linux is caching it. if it is, then freebsd should at least > have an option to do the same. the real test will be trying linux on the > freebsd hardware and freebsd on the linux hardware. i don't know when i'll > get a chance to do it, but i'll update the list with details when it > happens. > FWIW, my old dell > /usr/bin/time sysctl -n hw.acpi.battery.life hw.acpi.battery.time hw.acpi.battery.state 100 -1 0 0.01 real 0.00 user 0.01 sys -- Adam Vande More ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
On Wed, 14 Jul 2010, Joerg Sonnenberger wrote: On Wed, Jul 14, 2010 at 11:49:07PM +1200, Atom Smasher wrote: the same info is available on linux via /sys and /proc and on comparable hardware, i can get the info about 100x faster. Are you sure that Linux is not just caching the data? I know of at least one system where it takes more than 100ms to query the battery state due to extremely slow hardware, I wouldn't be surprised if you can do worse. == i don't know if linux is caching it. if it is, then freebsd should at least have an option to do the same. the real test will be trying linux on the freebsd hardware and freebsd on the linux hardware. i don't know when i'll get a chance to do it, but i'll update the list with details when it happens. -- ...atom http://atom.smasher.org/ 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808 - "Anyone who doubts that terrorists could smuggle a nuclear warhead into New York City should note that they could always wrap it in a bale of marijuana." -- Graham Allison, The Boston Globe 27 October 1999 ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
In the last episode (Jul 14), Joerg Sonnenberger said: > On Wed, Jul 14, 2010 at 11:49:07PM +1200, Atom Smasher wrote: > > the same info is available on linux via /sys and /proc and on comparable > > hardware, i can get the info about 100x faster. > > Are you sure that Linux is not just caching the data? I know of at least > one system where it takes more than 100ms to query the battery state due > to extremely slow hardware, I wouldn't be surprised if you can do worse. I have an old Dell laptop where it takes almost a full second to fetch battery data via ACPI. -- Dan Nelson dnel...@allantgroup.com ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
On Wed, 14 Jul 2010, Dominic Fandrey wrote: It probably depends on your BIOS. This is the same call on my system: % time sysctl -n hw.acpi.battery.life hw.acpi.battery.time hw.acpi.battery.state 100 -1 0 sysctl -n hw.acpi.battery.life hw.acpi.battery.time hw.acpi.battery.state 0.00s user 0.01s system 96% cpu 0.013 total As you can see 33 times faster than on your system. === next time i reboot this laptop, i'll stick an ubuntu CD in and see if it takes as long to get the info. i guess if it does take as long, then we can blame the hardware. -- ...atom http://atom.smasher.org/ 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808 - "Since I entered politics, I have chiefly had men's views confided to me privately. Some of the biggest men in the United States, in the Field of commerce and manufacture, are afraid of something. They know that there is a power somewhere so organized, so subtle, so watchful, so interlocked, so complete, so pervasive, that they better not speak above their breath when they speak in condemnation of it." -- Woodrow Wilson, The New Freedom (1913) ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
On Wed, Jul 14, 2010 at 11:49:07PM +1200, Atom Smasher wrote: > the same info is available on linux via /sys and /proc and on > comparable hardware, i can get the info about 100x faster. Are you sure that Linux is not just caching the data? I know of at least one system where it takes more than 100ms to query the battery state due to extremely slow hardware, I wouldn't be surprised if you can do worse. Joerg ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
On 14/07/2010 13:49, Atom Smasher wrote: > http://smasher.org/tmp/zsh-bsd-sysctl-slow.png Why use a screen shot here? > is there a way to get this information that doesn't take so long? > > the same info is available on linux via /sys and /proc and on comparable > hardware, i can get the info about 100x faster. It probably depends on your BIOS. This is the same call on my system: % time sysctl -n hw.acpi.battery.life hw.acpi.battery.time hw.acpi.battery.state 100 -1 0 sysctl -n hw.acpi.battery.life hw.acpi.battery.time hw.acpi.battery.state 0.00s user 0.01s system 96% cpu 0.013 total As you can see 33 times faster than on your system. I agree that 0.413 seconds is too long, but I don't think it makes sense to call this value more frequently than every 30 seconds. So I'd say it's more of an annoyance than a real problem. Regards -- A: Because it fouls the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"
Re: sysctl way too slow
* Atom Smasher wrote: > http://smasher.org/tmp/zsh-bsd-sysctl-slow.png > > is there a way to get this information that doesn't take so long? > > the same info is available on linux via /sys and /proc and on > comparable hardware, i can get the info about 100x faster. So what about other sysctls? Is it just these sysctls? It may be the case that these values are not simply read from some variable in the kernel, but really performs some hardware calls. Still, 436 msec is quite a lot of time. -- Ed Schouten WWW: http://80386.nl/ pgpcbRRsFxAZF.pgp Description: PGP signature
Re: sysctl way too slow
On Wednesday 14 July 2010 13:49:07 Atom Smasher wrote: > http://smasher.org/tmp/zsh-bsd-sysctl-slow.png > > is there a way to get this information that doesn't take so long? > > the same info is available on linux via /sys and /proc and on comparable > hardware, i can get the info about 100x faster. > > thanks... Maybe you are using the sysctls wrong. Did you read man 3 sysctl? --HPS ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"