Autoregulate vm swappiness cleanup
Hi,
this patch makes my system even more responsive,
I applied the patch over 2.6.0-test8-mm1.
I have a Glade v1 project that has these source files among others:
$ ls -l callbacks.[ch] interface.[ch] -rw-rw-r-- 1 zozo zozo 583241 okt 28 13:06 callbacks.c -rw-rw-r-- 1 zozo zozo 96592 okt 27 22:54 callbacks.h -rw-rw-r-- 1 zozo zozo 1090912 okt 27 22:54 interface.c -rw-rw-r-- 1 zozo zozo 1687 okt 27 22:54 interface.h
That said, among others: the projects is *very* large, and is reasonably modularised before someone says something silly about my programming capabilities. :-)
gcc-3.3.2 (latest Fedora packages) goes up 160M+ in memory usage, For a test run I started mozilla with some very long pages, oowriter, gedit with the listed files opened and some gnome-terminal and a new project compile with make -j2 so the callbacks.c and interface.c were compiled simultaneously.
The system is a dual PIII/500 MHz with 512M RAM, not a speedy machine. With all these, the system used only ~36M swap. Free memory was about 3-6M then I exited oowriter. Free mem suddenly went up to 75M+, starting programs was almost instant.
Definitely a win.
Signature · 6 lines
Best regards, Zoltán Böszörményi --------------------- What did Hussein say about his knife? One in Bush worth two in the hand.
On Tue, 28 Oct 2003, Boszormenyi Zoltan wrote:
[SNIPPED...]
Quoted 1 line
-rw-rw-r-- 1 zozo zozo 1090912 okt 27 22:54
interface.c
^^^^^^^
Guess you use vim to edit ...eh?
Linux does have a good linker, you know. You don't need to put everything in one file!
Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
Quoted 9 lines · Richard B. Johnson
On Tue, 28 Oct 2003, Boszormenyi Zoltan wrote:
[SNIPPED...]Quoted 1 line
-rw-rw-r-- 1 zozo zozo 1090912 okt 27 22:54
interface.c^^^^^^^Guess you use
vimto edit ...eh?Linux does have a good linker, you know. You don't need to put everything in one file!
On the flip side, if there's a lot of routines all declared 'static' so they are only visible to that .c file, it's less than simple to split them out and tell the *rest* of the projects that 'routines in interface/*.c are visible to each other, but not to C code in database/*.c'.
The Linux kernel has the same issues:
% find . -name '*.[ch]' | xargs grep acpi_bus_unregister_driver
referenced only in drivers/acpi and one include file - but pollutes the global linkage namespace all the same.
Quoted 16 lines · On Tue, 28 Oct 2003 [email protected] wrote:
Quoted 9 lines · Richard B. Johnson
On Tue, 28 Oct 2003, Boszormenyi Zoltan wrote:
[SNIPPED...]Quoted 1 line
-rw-rw-r-- 1 zozo zozo 1090912 okt 27 22:54
interface.c^^^^^^^Guess you use
vimto edit ...eh?Linux does have a good linker, you know. You don't need to put everything in one file!
On the flip side, if there's a lot of routines all declared 'static' so they are only visible to that .c file, it's less than simple to split them out and tell the *rest* of the projects that 'routines in interface/*.c are visible to each other, but not to C code in database/*.c'.
Quoted 7 lines
The Linux kernel has the same issues:
% find . -name '*.[ch]' | xargs grep
acpi_bus_unregister_driverreferenced only in
drivers/acpiand one include file - but pollutes the global linkage namespace all the same.
I keep hearing 'pollutes the global namespace' all the time, now. Do you mean that 'C' code designers actually intend to use the same name for different procedures or objects in different files?
If so, that's a problem of idiocy, not pollution. Anybody who writes code for a living would not do that, now would they??
The fact that there may be many global references that need to be resolved by the linker is not pollution. It's using tools to simplify design, implementation, testing, and maintenance.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.22 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.
Quoted 3 lines · Richard B. Johnson
I keep hearing 'pollutes the global namespace' all the time, now. Do you mean that 'C' code designers actually intend to use the same name for different procedures or objects in different files?
Right. Exactly.
That's why you need to have module1_debug_level, module2_debug_level, module3_debug_level and so on, rather than have a 'debug_level' that's visible in module1, another that's visible in module2, and a third that's visible in module3. Note that you *CAN* do that if module1, module2, and module3 are all *single* .c files simply by declaring it 'static int debug_level;'. But if you decide to splt module1 and module2 into 2 .c files each, suddenly you need to rename *both* variables....
And I'm *positive* that *nobody* on this list has done that, forgotten to rename the variables, and then wondered why module1 has 'debug_level = 1;' in it and the debugging output starts and then mysteriously stops some random time after (because module2 has 'debug_level = 0;' in it...)
Yes, C does not have a C++ idea of "private data". My point is that quite often, the use of 'static' to simulate it is the reason for very large .c files....
Quoted 5 lines · [email protected] writes:
And I'm *positive* that *nobody* on this list has done that, forgotten to rename the variables, and then wondered why module1 has '
debug_level= 1;' in it and the debugging output starts and then mysteriously stops some random time after (because module2 has 'debug_level= 0;' in it...)
Doing that mistake would give a linker error.
Signature · 2 lines
Måns Rullgård [email protected]
Quoted 1 line · On Tue, 28 Oct 2003 17:51:48 +0100, [email protected]…
Doing that mistake would give a linker error.
Not necessarily. Consider shared libraries. Load module1.so, load module2.so, and then load module3.so that has an unresolved reference that both of the other two happen to have. Oh wow.. results that are dependent on the order of -l flags in a non-obvious way... And '-z muldefs' is always a good way to shoot yourself in the foot.....
Yes, it's stupid, yes, it's a mistake - my point is that the design of C makes that sort of mistake more likely. If there *did* exist a "private to all the pieces of the module" status similar to the "private to THIS .c 'static'", it wouldn't be anywhere near the problem.
And don't tell me that the Linux kernel hasn't seen similar issues - a supposedly private interface that didn't have 'static' because it *was* called from 2 other .c files in the directory. And then we have to tell people "don't call that interface, it's private".
Richard B. Johnson írta:
Quoted 6 lines · Boszormenyi Zoltan
[SNIPPED...]
Quoted 1 line
-rw-rw-r-- 1 zozo zozo 1090912 okt 27 22:54
interface.c
Quoted 8 lines
^^^^^^^Guess you use
vimto edit ...eh?Linux does have a good linker, you know. You don't need to put everything in one file!
Cheers,
Dick Johnson
Ehm, yes, I know. But I guess you don't use Glade, do you? interface[.ch] are completely generated by Glade, all the create_windowXXX() functions are dumped into these files and created from scratch all the time you save/regenerate the project's source. The project grew over time, it's pretty large now.
Signature · 6 lines
Best regards, Zoltán Böszörményi --------------------- What did Hussein say about his knife? One in Bush worth two in the hand.