Date: Fri, 04 May 2007 18:03:53 +0400 From: valiy <valiy-td@mail.ru> To: freebsd-hackers@freebsd.org Subject: FreeBSD 6.1 6.2 C++ stl set.clear() very slow Message-ID: <463B3D49.7090101@mail.ru>
next in thread | raw e-mail | index | archive | help
test prog: #include <set> #include <stdlib.h> #include <stdio.h> #include <sys/time.h> timeval bgn, end; int main() { std::set<long long> s; printf("filling\n"); gettimeofday(&bgn, NULL); for (int i = 0; i < (1<<20); i++) { s.insert((rand() << 16) + rand()); } gettimeofday(&end, NULL); float t1 = float (end.tv_sec - bgn.tv_sec) + float (end.tv_usec - bgn.tv_usec) / 1000000.0f; printf("clearing\n"); gettimeofday(&bgn, NULL); s.clear(); gettimeofday(&end, NULL); float t2 = float (end.tv_sec - bgn.tv_sec) + float (end.tv_usec - bgn.tv_usec) / 1000000.0f; printf("done\n"); printf("alloc time %.3f\tclear time %.3f\n", t1, t2); } TEST1 FreeBSD idx 6.1-RELEASE-p10 FreeBSD 6.1-RELEASE-p10 #1: Wed Nov 8 18:59:20 UTC 2006 root@idx:/usr/src/sys/amd64/compile/SMP amd64 19:07:15 root@idx3 ~ $ g++ ./test_set.cpp 19:07:23 root@idx3 ~ $ ./a.out filling clearing done alloc time 1.938 clear time 15.290 dmesg: Copyright (c) 1992-2006 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 6.1-RELEASE-p10 #1: Wed Nov 8 18:59:20 UTC 2006 root@idx3.mail.ru:/usr/src/sys/amd64/compile/SMP ACPI APIC Table: <A M I OEMAPIC > Timecounter "i8254" frequency 1193182 Hz quality 0 CPU: Dual Core AMD Opteron(tm) Processor 275 (2200.01-MHz K8-class CPU) Origin = "AuthenticAMD" Id = 0x20f12 Stepping = 2 Features=0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2,HTT> Features2=0x1<SSE3> AMD Features=0xe2500800<SYSCALL,NX,MMX+,FFXSR,LM,3DNow+,3DNow> AMD Features2=0x3<LAHF,CMP> Cores per package: 2 real memory = 6979321856 (6656 MB) avail memory = 6215618560 (5927 MB) FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 cpu2 (AP): APIC ID: 2 cpu3 (AP): APIC ID: 3 ioapic0 <Version 1.1> irqs 0-23 on motherboard ioapic1 <Version 1.1> irqs 24-47 on motherboard kbd1 at kbdmux0 acpi0: <A M I OEMXSDT> on motherboard acpi0: Power Button (fixed) acpi0: reservation of dfefd000, 400 (3) failed acpi0: reservation of dfefe000, 400 (3) failed acpi0: reservation of dfeff000, 1000 (3) failed Timecounter "ACPI-safe" frequency 3579545 Hz quality 1000 acpi_timer0: <24-bit timer at 3.579545MHz> port 0x4008-0x400b on acpi0 cpu0: <ACPI CPU> on acpi0 cpu1: <ACPI CPU> on acpi0 cpu2: <ACPI CPU> on acpi0 cpu3: <ACPI CPU> on acpi0 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 pci0: <ACPI PCI bus> on pcib0 pci0: <memory> at device 0.0 (no driver attached) isab0: <PCI-ISA bridge> at device 1.0 on pci0 isa0: <ISA bus> on isab0 pci0: <serial bus, SMBus> at device 1.1 (no driver attached) ohci0: <OHCI (generic) USB controller> mem 0xfe4fd000-0xfe4fdfff irq 20 at device 2.0 on pci0 ohci0: [GIANT-LOCKED] usb0: OHCI version 1.0, legacy support usb0: SMM does not respond, resetting usb0: <OHCI (generic) USB controller> on ohci0 usb0: USB revision 1.0 uhub0: nVidia OHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 10 ports with 10 removable, self powered ehci0: <NVIDIA nForce4 USB 2.0 controller> mem 0xfe4e0000-0xfe4e00ff irq 21 at device 2.1 on pci0 ehci0: [GIANT-LOCKED] usb1: EHCI version 1.0 usb1: companion controller, 4 ports each: usb0 usb1: <NVIDIA nForce4 USB 2.0 controller> on ehci0 usb1: USB revision 2.0 uhub1: nVidia EHCI root hub, class 9/0, rev 2.00/1.00, addr 1 uhub1: 10 ports with 10 removable, self powered atapci0: <nVidia nForce CK804 UDMA133 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0x3000-0x300f at device 6.0 on pci0 ata0: <ATA channel 0> on atapci0 ata1: <ATA channel 1> on atapci0 atapci1: <nVidia nForce CK804 SATA300 controller> port 0xcc00-0xcc07,0xc800-0xc803,0xc400-0xc407,0xc000-0xc003,0xbc00-0xbc0f mem 0xfe4ff000-0xfe4fffff irq 22 at device 7.0 on pci0 ata2: <ATA channel 0> on atapci1 ata3: <ATA channel 1> on atapci1 atapci2: <nVidia nForce CK804 SATA300 controller> port 0xb800-0xb807,0xb400-0xb403,0xb000-0xb007,0xac00-0xac03,0xa800-0xa80f mem 0xfe4fe000-0xfe4fefff irq 20 at device 8.0 on pci0 ata4: <ATA channel 0> on atapci2 ata5: <ATA channel 1> on atapci2 pcib1: <ACPI PCI-PCI bridge> at device 9.0 on pci0 pci5: <ACPI PCI bus> on pcib1 pci5: <display, VGA> at device 4.0 (no driver attached) pcib2: <ACPI PCI-PCI bridge> at device 11.0 on pci0 pci4: <ACPI PCI bus> on pcib2 pcib3: <ACPI PCI-PCI bridge> at device 12.0 on pci0 pci2: <ACPI PCI bus> on pcib3 bge0: <Broadcom BCM5721 Gigabit Ethernet, ASIC rev. 0x4101> mem 0xfc1f0000-0xfc1fffff irq 17 at device 0.0 on pci2 miibus0: <MII bus> on bge0 brgphy0: <BCM5750 10/100/1000baseTX PHY> on miibus0 brgphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX, 1000baseTX-FDX, auto bge0: Ethernet address: 00:30:48:57:59:70 pcib4: <ACPI PCI-PCI bridge> at device 13.0 on pci0 pci3: <ACPI PCI bus> on pcib4 bge1: <Broadcom BCM5721 Gigabit Ethernet, ASIC rev. 0x4101> mem 0xfc2f0000-0xfc2fffff irq 18 at device 0.0 on pci3 miibus1: <MII bus> on bge1 brgphy1: <BCM5750 10/100/1000baseTX PHY> on miibus1 brgphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX, 1000baseTX-FDX, auto bge1: Ethernet address: 00:30:48:57:59:71 pcib5: <ACPI PCI-PCI bridge> at device 14.0 on pci0 pci1: <ACPI PCI bus> on pcib5 pcib6: <ACPI Host-PCI bridge> on acpi0 pci128: <ACPI PCI bus> on pcib6 pci128: <memory> at device 0.0 (no driver attached) pci128: <memory> at device 1.0 (no driver attached) atapci3: <nVidia nForce CK804 SATA300 controller> port 0xfc00-0xfc07,0xf800-0xf803,0xf400-0xf407,0xf000-0xf003,0xec00-0xec0f mem 0xfe6ff000-0xfe6fffff irq 44 at device 7.0 on pci128 ata6: <ATA channel 0> on atapci3 ata7: <ATA channel 1> on atapci3 atapci4: <nVidia nForce CK804 SATA300 controller> port 0xe800-0xe807,0xe400-0xe403,0xe000-0xe007,0xdc00-0xdc03,0xd800-0xd80f mem 0xfe6fe000-0xfe6fefff irq 45 at device 8.0 on pci128 ata8: <ATA channel 0> on atapci4 ata9: <ATA channel 1> on atapci4 pcib7: <ACPI PCI-PCI bridge> at device 13.0 on pci128 pci130: <ACPI PCI bus> on pcib7 pcib8: <ACPI PCI-PCI bridge> at device 14.0 on pci128 pci129: <ACPI PCI bus> on pcib8 acpi_button0: <Power Button> on acpi0 sio0: configured irq 4 not in bitmap of probed irqs 0 sio0: port may not be enabled sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 sio0: type 16550A sio1: configured irq 3 not in bitmap of probed irqs 0 sio1: port may not be enabled sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0 sio1: type 16550A fdc0: <floppy drive controller (FDE)> port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on acpi0 fdc0: [FAST] fd0: <1440-KB 3.5" drive> on fdc0 drive 0 ppc0: <Standard parallel printer port> port 0x378-0x37f irq 7 on acpi0 ppc0: Generic chipset (NIBBLE-only) in COMPATIBLE mode ppbus0: <Parallel port bus> on ppc0 plip0: <PLIP network interface> on ppbus0 lpt0: <Printer> on ppbus0 lpt0: Interrupt-driven port ppi0: <Parallel I/O> on ppbus0 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0 atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED] orm0: <ISA Option ROMs> at iomem 0xc0000-0xc7fff,0xc8000-0xc97ff,0xc9800-0xcafff on isa0 sc0: <System console> at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 Timecounters tick every 1.000 msec module_register_init: MOD_LOAD (amr_linux, 0xffffffff80622180, 0) error 6 ipfw2 (+ipv6) initialized, divert loadable, rule-based forwarding disabled, default to accept, logging disabled acd0: CDROM <CD-224E-N/1.AA> at ata0-master UDMA33 ad4: 76319MB <Seagate ST380811AS 3.AAE> at ata2-master SATA300 ad8: 381554MB <Seagate ST3400620AS 3.AAD> at ata4-master SATA300 ad10: 381554MB <Seagate ST3400620AS 3.AAD> at ata5-master SATA300 ad12: 381554MB <Seagate ST3400620NS 3.AEE> at ata6-master SATA300 ad14: 381554MB <Seagate ST3400620AS 3.AAD> at ata7-master SATA300 ad16: 381554MB <WDC WD4000YR-01PLB0 01.06A01> at ata8-master SATA150 ad18: 381554MB <WDC WD4000YR-01PLB0 01.06A01> at ata9-master SATA150 SMP: AP CPU #1 Launched! SMP: AP CPU #3 Launched! SMP: AP CPU #2 Launched! Trying to mount root from ufs:/dev/ad4s1a bge0: link state changed to UP TEST2 FreeBSD proton 5.5-RELEASE FreeBSD 5.5-RELEASE #0: Mon Jun 26 21:47:56 MSD 2006 root@proton:/usr/src/sys/i386/compile/PROTON i386 [root@proton ~]# g++ test_set.cpp [root@proton ~]# ./a.out filling clearing done alloc time 2.529 clear time 5.685 dmesg :kernel boot file is /boot/kernel/kernel Copyright (c) 1992-2006 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994 The Regents of the University of California. All rights reserved. FreeBSD 5.5-RELEASE #0: Mon Jun 26 21:47:56 MSD 2006 root@proton:/usr/src/sys/i386/compile/PROTON ACPI APIC Table: <PTLTD APIC > Timecounter "i8254" frequency 1193182 Hz quality 0 CPU: Intel(R) Xeon(TM) CPU 2.80GHz (2800.12-MHz 686-class CPU) Origin = "GenuineIntel" Id = 0xf43 Stepping = 3 Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE> Hyperthreading: 2 logical CPUs real memory = 7516192768 (7168 MB) avail memory = 6290010112 (5998 MB) FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs cpu0 (BSP): APIC ID: 0 cpu1 (AP): APIC ID: 1 cpu2 (AP): APIC ID: 6 cpu3 (AP): APIC ID: 7 ioapic0 <Version 2.0> irqs 0-23 on motherboard ioapic1 <Version 2.0> irqs 24-47 on motherboard ioapic2 <Version 2.0> irqs 48-71 on motherboard acpi0: <PTLTD RSDT> on motherboard acpi0: Power Button (fixed) Timecounter "ACPI-fast" frequency 3579545 Hz quality 1000 acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1008-0x100b on acpi0 cpu0: <ACPI CPU> on acpi0 cpu1: <ACPI CPU> on acpi0 cpu2: <ACPI CPU> on acpi0 cpu3: <ACPI CPU> on acpi0 pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0 pci0: <ACPI PCI bus> on pcib0 pci0: <unknown> at device 0.1 (no driver attached) pci0: <base peripheral> at device 1.0 (no driver attached) pcib1: <ACPI PCI-PCI bridge> irq 16 at device 2.0 on pci0 pci1: <ACPI PCI bus> on pcib1 pcib2: <ACPI PCI-PCI bridge> irq 16 at device 3.0 on pci0 pci2: <ACPI PCI bus> on pcib2 pcib3: <ACPI PCI-PCI bridge> at device 0.0 on pci2 pci3: <ACPI PCI bus> on pcib3 ahd0: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x2000-0x20ff,0x2400-0x24ff mem 0xdd200000-0xdd201fff irq 32 at device 2.0 on pci3 aic7902: Ultra320 Wide Channel A, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs ahd1: <Adaptec AIC7902 Ultra320 SCSI adapter> port 0x2800-0x28ff,0x2c00-0x2cff mem 0xdd202000-0xdd203fff irq 33 at device 2.1 on pci3 aic7902: Ultra320 Wide Channel B, SCSI Id=7, PCI-X 67-100Mhz, 512 SCBs pci2: <base peripheral, interrupt controller> at device 0.1 (no driver attached) pcib4: <ACPI PCI-PCI bridge> at device 0.2 on pci2 pci4: <ACPI PCI bus> on pcib4 em0: <Intel(R) PRO/1000 Network Connection, Version - 1.7.35> port 0x3000-0x303f mem 0xdd300000-0xdd31ffff irq 54 at device 2.0 on pci4 em0: Ethernet address: 00:30:48:2f:b0:e2 em1: <Intel(R) PRO/1000 Network Connection, Version - 1.7.35> port 0x3040-0x307f mem 0xdd320000-0xdd33ffff irq 55 at device 2.1 on pci4 em1: Ethernet address: 00:30:48:2f:b0:e3 pci2: <base peripheral, interrupt controller> at device 0.3 (no driver attached) pcib5: <ACPI PCI-PCI bridge> irq 16 at device 4.0 on pci0 pci5: <ACPI PCI bus> on pcib5 pcib6: <ACPI PCI-PCI bridge> irq 16 at device 6.0 on pci0 pci6: <ACPI PCI bus> on pcib6 pci0: <serial bus, USB> at device 29.0 (no driver attached) pci0: <serial bus, USB> at device 29.1 (no driver attached) pci0: <serial bus, USB> at device 29.2 (no driver attached) pci0: <serial bus, USB> at device 29.3 (no driver attached) pci0: <serial bus, USB> at device 29.7 (no driver attached) pcib7: <ACPI PCI-PCI bridge> at device 30.0 on pci0 pci7: <ACPI PCI bus> on pcib7 pci7: <display, VGA> at device 1.0 (no driver attached) isab0: <PCI-ISA bridge> at device 31.0 on pci0 isa0: <ISA bus> on isab0 atapci0: <Intel ICH5 UDMA100 controller> port 0x14a0-0x14af,0x376,0x170-0x177,0x3f6,0x1f0-0x1f7 at device 31.1 on pci0 ata0: channel #0 on atapci0 ata1: channel #1 on atapci0 pci0: <serial bus, SMBus> at device 31.3 (no driver attached) acpi_button0: <Power Button> on acpi0 ppc0: <ECP parallel printer port> port 0x778-0x77f,0x378-0x37f irq 7 drq 1 on acpi0 ppc0: Generic chipset (ECP/PS2/NIBBLE) in COMPATIBLE mode ppc0: FIFO with 16/16/8 bytes threshold ppbus0: <Parallel port bus> on ppc0 plip0: <PLIP network interface> on ppbus0 lpt0: <Printer> on ppbus0 lpt0: Interrupt-driven port ppi0: <Parallel I/O> on ppbus0 atkbdc0: <Keyboard controller (i8042)> port 0x64,0x60 irq 1 on acpi0 atkbd0: <AT Keyboard> irq 1 on atkbdc0 kbd0 at atkbd0 sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0 sio0: type 16550A sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0 sio1: type 16550A fdc0: <floppy drive controller> port 0x3f7,0x3f0-0x3f5 irq 6 drq 2 on acpi0 fd0: <1440-KB 3.5" drive> on fdc0 drive 0 npx0: <math processor> on motherboard npx0: INT 16 interface orm0: <ISA Option ROMs> at iomem 0xc9000-0xd2fff,0xc8000-0xc8fff,0xc0000-0xc7fff on isa0 pmtimer0 on isa0 sc0: <System console> at flags 0x100 on isa0 sc0: VGA <16 virtual consoles, flags=0x300> vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0 Timecounters tick every 10.000 msecda0: <FUJITSU MAT3073NC 0109> Fixed Direct Access SCSI-3 device da0: 320.000MB/s transfers (160.000MHz, offset 127, 16bit), Tagged Queueing Enabled da0: 70136MB (143638992 512 byte sectors: 255H 63S/T 8941C) da1 at ahd0 bus 0 target 1 lun 0 da1: <FUJITSU MAW3300NC 0104> Fixed Direct Access SCSI-3 device da1: 320.000MB/s transfers (160.000MHz, offset 127, 16bit), Tagged Queueing Enabled da1: 286102MB (585937500 512 byte sectors: 255H 63S/T 36472C) da2 at ahd0 bus 0 target 2 lun 0 da2: <FUJITSU MAW3300NC 0104> Fixed Direct Access SCSI-3 device da2: 320.000MB/s transfers (160.000MHz, offset 127, 16bit), Tagged Queueing Enabled da2: 286102MB (585937500 512 byte sectors: 255H 63S/T 36472C) da3 at ahd1 bus 0 target 0 lun 0 da3: <MAXTOR ATLAS15K2_36SCA JNZH> Fixed Direct Access SCSI-3 device da3: 320.000MB/s transfers (160.000MHz, offset 127, 16bit), Tagged Queueing Enabled da3: 35074MB (71833096 512 byte sectors: 255H 63S/T 4471C) da4 at ahd1 bus 0 target 1 lun 0 da4: <FUJITSU MAW3300NC 0104> Fixed Direct Access SCSI-3 device da4: 320.000MB/s transfers (160.000MHz, offset 127, 16bit), Tagged Queueing Enabled da4: 286102MB (585937500 512 byte sectors: 255H 63S/T 36472C) da5 at ahd1 bus 0 target 2 lun 0 da5: <FUJITSU MAU3036NC 0105> Fixed Direct Access SCSI-3 device da5: 320.000MB/s transfers (160.000MHz, offset 127, 16bit), Tagged Queueing Enabled da5: 35068MB (71819496 512 byte sectors: 255H 63S/T 4470C) SMP: AP CPU #3 Launched! SMP: AP CPU #1 Launched! SMP: AP CPU #2 Launched! ipfw2 initialized, divert disabled, rule-based forwarding disabled, default to accept, logging disabled Waiting 15 seconds for SCSI devices to settle da0 at ahd0 bus 0 target 0 lun 0 da0: <FUJITSU MAT3073NC 0109> Fixed Direct Access SCSI-3 device TEST3: FreeBSD hotdog 4.9-RELEASE FreeBSD 4.9-RELEASE #3: Fri Jul 1 19:35:10 MSD 2005 root@hotdog:/usr/src/sys/compile/HOTDOG i386 19:18 root@puma vvolodin $ ./a.out filling clearing done alloc time 4.001 clear time 0.305 pentium3 2x700MHz how to fix?
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?463B3D49.7090101>