Re: Re: sysctl, HW_PHYSMEM, and crippled gcc
On Fri, Dec 09, 2005 at 02:02:25PM -0600, Sergey Babkin wrote: From: Divacky Roman [EMAIL PROTECTED] On Thu, Dec 08, 2005 at 05:06:16PM -0800, Steve Kargl wrote: Anyone have any insight into fixing gcc to make better use of system memory on systems with more than 4 GB. It appears that libiberty/physmem.c tries to use sysctl() to determine the amount of physical memory in a system. { /* This works on *bsd and darwin. */ unsigned int physmem; size_t len = sizeof physmem; static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), physmem, len, NULL, 0) == 0 len == sizeof (physmem)) return (double) physmem; } This works if you have less than 4GB because of the unsigned int physmem. I have 12 GB, which of course, when expanded to the number of bytes doesn't fit into a unsigned int physmem. In particular, ggc-min-heapsize=4096 is ridiculously small for a system with 12 GB of memory. the code works here (512M of memory)... dont know about the ifdefs its surrounded by.. I guess you've confused M and G :-) The point is that it breaks with over 4G of memory. dan nelson reported he has the same value with all machine with various ram sizes. so he presumed the code doesnt work at all... and it did for me ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: sysctl, HW_PHYSMEM, and crippled gcc
On Thu, Dec 08, 2005 at 05:06:16PM -0800, Steve Kargl wrote: Anyone have any insight into fixing gcc to make better use of system memory on systems with more than 4 GB. It appears that libiberty/physmem.c tries to use sysctl() to determine the amount of physical memory in a system. { /* This works on *bsd and darwin. */ unsigned int physmem; size_t len = sizeof physmem; static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), physmem, len, NULL, 0) == 0 len == sizeof (physmem)) return (double) physmem; } This works if you have less than 4GB because of the unsigned int physmem. I have 12 GB, which of course, when expanded to the number of bytes doesn't fit into a unsigned int physmem. What is the ramification? Well, gcc uses this estimate of memory to size internal parameters. troutmask:sgk[259] gcc -v h.c Using built-in specs. Configured with: FreeBSD/amd64 system compiler Thread model: posix gcc version 3.4.4 [FreeBSD] 20050518 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 In particular, ggc-min-heapsize=4096 is ridiculously small for a system with 12 GB of memory. the code works here (512M of memory)... dont know about the ifdefs its surrounded by.. if you manually rewrite the physmem to some bigger value - does it have any effect on performance of gcc? roman ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Re: sysctl, HW_PHYSMEM, and crippled gcc
From: Divacky Roman [EMAIL PROTECTED] On Thu, Dec 08, 2005 at 05:06:16PM -0800, Steve Kargl wrote: Anyone have any insight into fixing gcc to make better use of system memory on systems with more than 4 GB. It appears that libiberty/physmem.c tries to use sysctl() to determine the amount of physical memory in a system. { /* This works on *bsd and darwin. */ unsigned int physmem; size_t len = sizeof physmem; static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), physmem, len, NULL, 0) == 0 len == sizeof (physmem)) return (double) physmem; } This works if you have less than 4GB because of the unsigned int physmem. I have 12 GB, which of course, when expanded to the number of bytes doesn't fit into a unsigned int physmem. In particular, ggc-min-heapsize=4096 is ridiculously small for a system with 12 GB of memory. the code works here (512M of memory)... dont know about the ifdefs its surrounded by.. I guess you've confused M and G :-) The point is that it breaks with over 4G of memory. -SB ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: sysctl, HW_PHYSMEM, and crippled gcc
On Thu, Dec 08, 2005 at 10:05:48PM -0600, Dan Nelson wrote: In the last episode (Dec 08), Steve Kargl said: Anyone have any insight into fixing gcc to make better use of system memory on systems with more than 4 GB. It appears that libiberty/physmem.c tries to use sysctl() to determine the amount of physical memory in a system. { /* This works on *bsd and darwin. */ unsigned int physmem; size_t len = sizeof physmem; static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), physmem, len, NULL, 0) == 0 len == sizeof (physmem)) return (double) physmem; } This works if you have less than 4GB because of the unsigned int physmem. I have 12 GB, which of course, when expanded to the number of bytes doesn't fit into a unsigned int physmem. physmem is actually an unsigned long, not an unsigned int, so on amd64 that sysctl call should fail anyway (amd64 is LP64, so a long won't fit into an int). I changed unsigned int physmem; to size_t physmem;. Now, the 12 GB are recognized. gcc version 3.4.4 [FreeBSD] 20050518 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 In particular, ggc-min-heapsize=4096 is ridiculously small for a system with 12 GB of memory. On all my FreeBSD boxes from 128MB to 1GB of RAM, I get the exact same heuristic values as you, so I'm not sure whether the code works at all. I forced physmem to be 8196 and recompiled gcc. For whatever reason, ggc-min-heapsize=4096 was still reported, but my compiling problems disappeared. I think you may be right about the code not doing working as the programmer may have thought. -- Steve ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: Re: sysctl, HW_PHYSMEM, and crippled gcc
On 2005-12-09 14:02, Sergey Babkin [EMAIL PROTECTED] wrote: Divacky Roman [EMAIL PROTECTED] wrote: On Thu, Dec 08, 2005 at 05:06:16PM -0800, Steve Kargl wrote: Anyone have any insight into fixing gcc to make better use of system memory on systems with more than 4 GB. It appears that libiberty/physmem.c tries to use sysctl() to determine the amount of physical memory in a system. { /* This works on *bsd and darwin. */ unsigned int physmem; size_t len = sizeof physmem; static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), physmem, len, NULL, 0) == 0 len == sizeof (physmem)) return (double) physmem; } This works if you have less than 4GB because of the unsigned int physmem. I have 12 GB, which of course, when expanded to the number of bytes doesn't fit into a unsigned int physmem. In particular, ggc-min-heapsize=4096 is ridiculously small for a system with 12 GB of memory. the code works here (512M of memory)... dont know about the ifdefs its surrounded by.. I guess you've confused M and G :-) The point is that it breaks with over 4G of memory. Can someone with access to a system with more than 4 GB verify that the following works correctly? % flame:/home/keramida/tmp/physmem$ cat -n physmem.c % 1 #include sys/types.h % 2 #include sys/sysctl.h % 3 % 4 #include err.h % 5 #include stdint.h % 6 #include stdio.h % 7 #include stdlib.h % 8 % 9 int % 10 main(void) % 11 { % 12 uint64_t physmem; % 13 size_t len = sizeof physmem; % 14 static int mib[] = { CTL_HW, HW_PHYSMEM }; % 15 static size_t miblen = sizeof(mib) / sizeof(mib[0]); % 16 % 17 if (sysctl(mib, miblen, physmem, len, NULL, 0) != 0) % 18 err(1, sysctl hw.physmem); % 19 printf(Physical memory = %ju bytes\n, (intmax_t)physmem); % 20 return EXIT_SUCCESS; % 21 } % flame:/home/keramida/tmp/physmem$ ./physmem % Physical memory = 526151680 bytes % flame:/home/keramida/tmp/physmem$ Then we can probably try to push a similar change towards the libiberty developers too, unless there are serious problems with supporting uint64_t on some of the platforms that libiberty needs to run on. ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: sysctl, HW_PHYSMEM, and crippled gcc
In the last episode (Dec 10), Giorgos Keramidas said: On Thu, Dec 08, 2005 at 05:06:16PM -0800, Steve Kargl wrote: Anyone have any insight into fixing gcc to make better use of system memory on systems with more than 4 GB. It appears that libiberty/physmem.c tries to use sysctl() to determine the amount of physical memory in a system. { /* This works on *bsd and darwin. */ unsigned int physmem; size_t len = sizeof physmem; static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), physmem, len, NULL, 0) == 0 len == sizeof (physmem)) return (double) physmem; } This works if you have less than 4GB because of the unsigned int physmem. I have 12 GB, which of course, when expanded to the number of bytes doesn't fit into a unsigned int physmem. Can someone with access to a system with more than 4 GB verify that the following works correctly? % flame:/home/keramida/tmp/physmem$ cat -n physmem.c % 9 int % 10 main(void) % 11 { % 12 uint64_t physmem; % 13 size_t len = sizeof physmem; % 14 static int mib[] = { CTL_HW, HW_PHYSMEM }; % 15 static size_t miblen = sizeof(mib) / sizeof(mib[0]); % 16 % 17 if (sysctl(mib, miblen, physmem, len, NULL, 0) != 0) % 18 err(1, sysctl hw.physmem); % 19 printf(Physical memory = %ju bytes\n, (intmax_t)physmem); % 20 return EXIT_SUCCESS; % 21 } Won't this break on x86, where physmem is 32 bits? Just use unsigned long, which is what the sysctl type is according to kern_mib.c . -- Dan Nelson [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: sysctl, HW_PHYSMEM, and crippled gcc
In the last episode (Dec 08), Steve Kargl said: Anyone have any insight into fixing gcc to make better use of system memory on systems with more than 4 GB. It appears that libiberty/physmem.c tries to use sysctl() to determine the amount of physical memory in a system. { /* This works on *bsd and darwin. */ unsigned int physmem; size_t len = sizeof physmem; static int mib[2] = { CTL_HW, HW_PHYSMEM }; if (sysctl (mib, ARRAY_SIZE (mib), physmem, len, NULL, 0) == 0 len == sizeof (physmem)) return (double) physmem; } This works if you have less than 4GB because of the unsigned int physmem. I have 12 GB, which of course, when expanded to the number of bytes doesn't fit into a unsigned int physmem. physmem is actually an unsigned long, not an unsigned int, so on amd64 that sysctl call should fail anyway (amd64 is LP64, so a long won't fit into an int). What is the ramification? Well, gcc uses this estimate of memory to size internal parameters. troutmask:sgk[259] gcc -v h.c Using built-in specs. Configured with: FreeBSD/amd64 system compiler Thread model: posix gcc version 3.4.4 [FreeBSD] 20050518 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 In particular, ggc-min-heapsize=4096 is ridiculously small for a system with 12 GB of memory. On all my FreeBSD boxes from 128MB to 1GB of RAM, I get the exact same heuristic values as you, so I'm not sure whether the code works at all. I seem to remember having the opposite problem on a memory-limited machine which insisted in allocating a relatively huge percentage of RAM for a sort, and gnu sort uses the same physmem() call for its dynamic sizing. -- Dan Nelson [EMAIL PROTECTED] ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]