{"id":1599,"date":"2005-10-13T10:03:00","date_gmt":"2005-10-13T10:03:00","guid":{"rendered":"http:\/\/t.motd.kr\/articles\/1599\/java"},"modified":"2022-12-28T01:48:00","modified_gmt":"2022-12-27T16:48:00","slug":"%ec%9e%90%eb%b0%94-java-%ed%8d%bc%ed%8f%ac%eb%a8%bc%ec%8a%a4%ec%97%90-%eb%8c%80%ed%95%9c-%eb%af%b8%ec%8b%a0%eb%93%a4","status":"publish","type":"post","link":"https:\/\/vault.motd.kr\/wordpress\/posts\/1599\/%ec%9e%90%eb%b0%94-java-%ed%8d%bc%ed%8f%ac%eb%a8%bc%ec%8a%a4%ec%97%90-%eb%8c%80%ed%95%9c-%eb%af%b8%ec%8b%a0%eb%93%a4\/","title":{"rendered":"\uc790\ubc14 (Java) \ud37c\ud3ec\uba3c\uc2a4\uc5d0 \ub300\ud55c \ubbf8\uc2e0\ub4e4"},"content":{"rendered":"\n
Java Theory and Practice<\/a> \uc2dc\ub9ac\uc988 \uc911 Urban Performance Legends<\/a>, Urban Performance Legends, Revisited<\/a> \uadf8\ub9ac\uace0 \uc81c\uc784\uc2a4 \uace0\uc2ac\ub9c1\uc758 \uc5b8\uae09<\/a>\uc744 \uc694\uc57d\ud588\uc2b5\ub2c8\ub2e4. \uc544\uc9c1\ub3c4(!) \ub204\uad70\uac00 \uc790\ubc14\uc758 \uc131\ub2a5 \ubb38\uc81c\ub97c \uc774\uc57c\uae30\ud55c\ub2e4\uba74, \uc774\uc815\ub3c4 \uc9c0\uc2dd\uacfc \ud37c\ud3ec\uba3c\uc2a4 \ud504\ub85c\ud30c\uc77c\ub9c1\uc5d0 \ub300\ud55c \uae30\ubcf8\uc801\uc778 \uc9c0\uc2dd\uc73c\ub85c \ucda9\ubd84\ud558\uc9c0 \uc54a\uc744\uae4c \uc2f6\uc2b5\ub2c8\ub2e4.<\/p>\n\n\n\n \uc694\uc998 JVM \uc740 \ucd5c\uc801\ud654\ub97c \ud1b5\ud574 \ud544\uc694 \uc5c6\ub294 \uacbd\uc6b0 \uc778\ub371\uc2a4 \uac80\uc0ac\ub97c \uc804\ud600 \ud558\uc9c0 \uc54a\ub294\ub2e4.<\/p>\n\n\n\n JDK 1.0 \uc2dc\uc808\uc5d0\ub294 \uadf8\ub7ac\uaca0\uc9c0\ub9cc \uc9c0\uae08\uc740 \uadf8\ub807\uc9c0 \uc54a\ub2e4. \uc5b4\ub5a4 \ucef4\ud30c\uc77c\ub7ec\ub294 \ucf54\ub4dc\ub97c \ubd84\uc11d\ud574 \ub3d9\uae30\ud654\uac00 \ud544\uc694 \uc5c6\uc744 \uacbd\uc6b0 \uc790\ub3d9\uc73c\ub85c \ub3d9\uae30\ud654 \ucf54\ub4dc\ub97c \uc81c\uac70\ud558\uae30\ub3c4 \ud55c\ub2e4. \uadf8\ub807\uc9c0 \uc54a\ub2e4 \ud558\ub354\ub77c\ub3c4 \uacbd\uc7c1 \uc0c1\ud0dc\uc5d0 \uc788\uc9c0 \uc54a\uc740 \uacbd\uc6b0 \uc131\ub2a5 \uc800\ud558\ub294 \ud06c\uc9c0 \uc54a\ub2e4. \uad1c\ud788 \uc774 \ubbf8\uc2e0\uc744 \ubbff\uace0 thread-safety \ub97c \uae68\uc9c0 \ub9c8\ub77c.<\/p>\n\n\n\n \uc804\ud600 \uadfc\uac70 \uc5c6\ub2e4. \uc18c\ud504\ud2b8\uc6e8\uc5b4\uc758 \ub514\uc790\uc778\ub9cc \ud76c\uc0dd\uc2dc\ud0a8\ub2e4.<\/p>\n\n\n\n Immutable \uac1c\ucc44\uc640 Mutable \uac1c\uccb4\uc758 \uc131\ub2a5 \ube44\uad50\ub294 \ub9e4\uc6b0 \uc5b4\ub835\ub2e4. \uac1c\uccb4\uc5d0 \uc804\ub2ec\ub420 \ub370\uc774\ud130\uac00 \uc900\ube44\ub420 \ub54c\uae4c\uc9c0\uc758 \uacfc\uc815\uc774 \ud070 \uc601\ud5a5\uc744 \ubbf8\uce58\uae30 \ub54c\ubb38\uc774\ub2e4. \ub530\ub77c\uc11c \ub2e8\uc815\ud560 \uc218 \uc5c6\uace0, \ub610 \uc131\ub2a5\uc744 \uc704\ud574 \uc18c\ud504\ud2b8\uc6e8\uc5b4 \ub514\uc790\uc778\uc744 \ud76c\uc0dd\uc2dc\ucf1c\uc57c \ud560 \uc815\ub3c4\ub3c4 \ubabb\ub41c\ub2e4.<\/p>\n\n\n\n \uc815\ud655\ud788 \uadf8 \ubc18\ub300\ub2e4. Sun JVM\uc740 \uc774\ub294 \ub9c8\uce58 \ud658\ud615 \ud050 (Circular Queue) \uc758 \ub3d9\uc791 \uc6d0\ub9ac\ub97c \ubcf4\ub294 \ub4ef \ud558\ub2e4. \ub2e4\ub9cc \uc0ac\uc6a9\ud558\ub294 \ud799 \uc601\uc5ed\uc774 \ud799 \uc601\uc5ed\uc758 \ub05d\uc790\ub77d\uc5d0 \ub2e4\ub2e4\ub790\uc744 \ub54c\uc5d0\ub294 GC \uac00 \uc77c\uc5b4\ub098 \uc131\ub2a5 \uc800\ud558\ub97c \uc720\ubc1c\ud558\uac8c \ub41c\ub2e4. \ub300\uc2e0 \ub300\ubd80\ubd84\uc758 \uc0c1\ud669\uc5d0\uc11c \ub300\ubd80\ubd84\uc758 \uac1c\uccb4\ub294 \uc911\uac04\uc5d0 \uc7a0\uc2dc \ub3d9\uc548 \uc0ac\uc6a9\ub418\uace0 \ubc84\ub824\uc9c0\uace0, \uc77c\ubd80\ub9cc\uc774 \u2018old\u2019 \uc138\ub300\ub85c \uc774\ub3d9\ub41c\ub2e4\ub294 \uac00\uc815\uc744 \uc6b0\ub9ac\ub294 \u2018\uc138\ub300 \uac00\uc124\u2019 (generational hypothesis) \uc774\ub77c \ubd80\ub978\ub2e4. \uc774 \uac00\uc124\uc740 \uacbd\ud5d8\uc801\uc73c\ub85c \ub300\ubd80\ubd84\uc758 \uac1c\uccb4 \uc9c0\ud5a5 \uc5b8\uc5b4\uc5d0\uc11c \uc0ac\uc2e4\uc784\uc774 \uc54c\ub824\uc838 \uc788\uace0, \ub530\ub77c\uc11c \uac00\ubca0\uc9c0 \uceec\ub809\ud130\ub294 \ub300\ubd80\ubd84\uc758 \uac1c\uccb4\uc5d0 \ub300\ud574 \ud560\ub2f9\uc774 \ube60\ub97c \ubfd0 \uc544\ub2c8\ub77c \ud574\uc81c \ube44\uc6a9\ub3c4 \uac70\uc758 \uc5c6\ub2e4.<\/p>\n\n\n\n \ubc88\uc5ed\ud558\uae30 \uadc0\ucc2e\uc544\uc11c \uc6d0\ubb38\uc73c\ub85c \uc2e3\uc2b5\ub2c8\ub2e4. \uac04\ub2e8\ud788, There was a funny incident at a recent developer event where some folks had a booth where they where demo-ing a high end industrial strength C compiler and had a benchmark that they had transliterated into Java. They were comparing their compiler to GCC and Java. GCC was running at about 2\/3 the performance of this high end compiler; the Java version was running at about 2\/3 the performance of the GCC version. Folks were gathered around the booth and someone noticed that the script they were using to run the Java version didn\u2019t have optimisation turned on. A few seconds with vi to add the \u201c-server\u201d switch and Java\u2019s performance jumped up to match the fancy C compiler. This got the pro-GCC crowd all excited, so a bunch of them started fiddling with its command line switches. They got a bit of improvement, but not much (the original selection had been pretty good).<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":" Java Theory and Practice \uc2dc\ub9ac\uc988 \uc911 Urban Performance Legends, Urban Performance Legends, Revisited \uadf8\ub9ac\uace0 \uc81c\uc784\uc2a4 \uace0\uc2ac\ub9c1\uc758 \uc5b8\uae09\uc744 \uc694\uc57d\ud588\uc2b5\ub2c8\ub2e4. \uc544\uc9c1\ub3c4(!) \ub204\uad70\uac00 \uc790\ubc14\uc758 \uc131\ub2a5 \ubb38\uc81c\ub97c \uc774\uc57c\uae30\ud55c\ub2e4\uba74, \uc774\uc815\ub3c4 \uc9c0\uc2dd\uacfc \ud37c\ud3ec\uba3c\uc2a4 \ud504\ub85c\ud30c\uc77c\ub9c1\uc5d0 \ub300\ud55c \uae30\ubcf8\uc801\uc778 \uc9c0\uc2dd\uc73c\ub85c \ucda9\ubd84\ud558\uc9c0 \uc54a\uc744\uae4c \uc2f6\uc2b5\ub2c8\ub2e4. Java \ub294 \ubc30\uc5f4 \uc778\ub371\uc2a4 \uac80\uc0ac\ub97c \ud558\uae30 \ub54c\ubb38\uc5d0 \ub290\ub9ac\ub2e4. \uc694\uc998 JVM \uc740 \ucd5c\uc801\ud654\ub97c \ud1b5\ud574 \ud544\uc694 \uc5c6\ub294 \uacbd\uc6b0 \uc778\ub371\uc2a4 \uac80\uc0ac\ub97c \uc804\ud600 \ud558\uc9c0 \uc54a\ub294\ub2e4…. Continue reading Java \ub294 \ubc30\uc5f4 \uc778\ub371\uc2a4 \uac80\uc0ac\ub97c \ud558\uae30 \ub54c\ubb38\uc5d0 \ub290\ub9ac\ub2e4.<\/h3>\n\n\n\n
synchronized<\/code>\ub294 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\uc558\uc744 \ub54c\ubcf4\ub2e4 50\ubc30 \ub290\ub9ac\ub2e4.<\/h3>\n\n\n\n
\ud074\ub798\uc2a4\ub098 \uba54\uc18c\ub4dc\ub97c
final<\/code> \ub85c \uc120\uc5b8\ud558\uba74 \uc131\ub2a5\uc774 \ud5a5\uc0c1\ub41c\ub2e4.<\/h3>\n\n\n\n
Immutable \uac1c\uccb4\ub294 \uc131\ub2a5\uc5d0 \uc545\uc601\ud5a5\uc744 \uc900\ub2e4.<\/h3>\n\n\n\n
\uc790\ubc14 \uba54\ubaa8\ub9ac \ud560\ub2f9\u00b7\ud574\uc81c\ub294 C\/C++ \ubcf4\ub2e4 \ub290\ub9ac\ub2e4.<\/h3>\n\n\n\n
new Object()<\/code> \ub97c \ud55c \ubc88 \uc218\ud589\ud558\ub294\ub370 10\uac1c\uc758 \uba38\uc2e0 \uc778\uc2a4\ud2b8\ub7ed\uc158\uc774\uba74 \ucda9\ubd84\ud558\uc9c0\ub9cc
malloc<\/code> \ub294 \ud638\ucd9c\ub2f9 60\uc5d0\uc11c 100 \uac1c\uc758 \uc778\uc2a4\ud2b8\ub7ed\uc158\uc774 \ud544\uc694\ud558\ub2e4. Perl \uc774\ub098 GhostScript \uac19\uc740 \uc5b4\ud50c\ub9ac\ucf00\uc774\uc158\uc740
malloc<\/code> \ud638\ucd9c\uc5d0 \uc2e4\ud589 \uc2dc\uac04\uc758 20~30% \ub97c \uc18c\ubaa8\ud560 \uc815\ub3c4\ub2e4. \uc798 \uc791\uc131\ub41c \uc790\ubc14 \uc5b4\ud50c\ub9ac\ucf00\uc774\uc158\uc758 \ud560\ub2f9\u00b7GC \uc2dc\uac04\uc744 \ub2e4 \ud569\uce5c \uac83\uc774 \ub354 \ud6a8\uc728\uc801\uc778 \uac83\uc73c\ub85c \uc54c\ub824\uc838 \uc788\ub2e4. \uc774\ub294 \ub2e4\ub978 \uc5b8\uc5b4\uc5d0 \uac00\ube44\uc9c0 \ucf5c\ub809\ud130 (Garbage Collector) \ub97c \uc801\uc6a9\ud588\uc744 \ub54c\ub3c4 \ub9c8\ucc2c\uac00\uc9c0\ub2e4.<\/p>\n\n\n\n
malloc<\/code> \uc758 \uacbd\uc6b0 \ud55c \ubc88\uc5d0 \ud544\uc694\ud55c \uc591\ub9cc\ud07c\uc758 \uba54\ubaa8\ub9ac\ub97c \ub9e4 \ubc88 \ud560\ub2f9\ud558\ub294 \ubc18\uba74, \uac00\ubca0\uc9c0 \ucf5c\ub809\ud130\uc758 \uacbd\uc6b0 \ud55c \ubc88\uc5d0 \ub300\ub7c9\uc758 \uba54\ubaa8\ub9ac\ub97c \ud560\ub2f9\ud558\uc5ec \uc790\uc720\ub86d\uac8c \ud65c\uc6a9\ud558\uae30 \ub54c\ubb38\uc774\ub2e4. \uc77c\ubc18\uc801\uc778 \uac00\ube44\uc9c0 \ucf5c\ub809\ud130\ub294 \ud799 \uc601\uc5ed\uc744 \u2018young\u2019 \uacfc \u2018old\u2019 \ub85c \ub098\ub204\uc5b4 \ud65c\uc6a9\ud55c\ub2e4. \ucd5c\ucd08\uc758 \uba54\ubaa8\ub9ac \ud560\ub2f9\uc740 \u2018young\u2019 \uc138\ub300 (generation) \uc5d0\uc11c \uc77c\uc5b4\ub098\uace0, \u2018young\u2019 \uc138\ub300\ub97c \uc77c\uc815 \uc2dc\uac04 \ub3d9\uc548 \uc0b4\uc544\ub0a8\uc740 \uac1c\uccb4\ub294 \u2018old\u2019 \uc138\ub300 \uc601\uc5ed\uc73c\ub85c \ub118\uc5b4\uac00\uac8c \ub41c\ub2e4. \uadf8\ub7f0\ub370 \uac00\ubca0\uc9c0 \ucf5c\ub809\ud130\ub294 \u2018young\u2019 \uc138\ub300 \ud799 \uc601\uc5ed\uc758 \uc808\ubc18\ub9cc \uc0ac\uc6a9\ud558\uace0, \ub098\uba38\uc9c0 \uc808\ubc18\uc740 \uc0ac\uc6a9\ud558\uc9c0 \uc54a\ub294\ub2e4. \ub300\uc2e0 \uba54\ubaa8\ub9ac \ud560\ub2f9 \ucf54\ub4dc\ub294 \ucd5c\ub300\ud55c \ub2e8\uc21c\ud558\uac8c \uc720\uc9c0\ud55c\ub2e4:<\/p>\n\n\n\n
void *malloc(int n) {\n if (heapTop - heapStart < n)\n doGarbageCollection();\n\n void *wasStart = heapStart;\n heapStart += n;\n\n return wasStart;\n}<\/code><\/pre>\n\n\n\n
malloc<\/code> \ubcf4\ub2e4 \uc6d4\ub4f1\ud55c \uc131\ub2a5\uc744 \ubcf4\uc7a5\ud55c\ub2e4. \ub610\ud55c \u2018young\u2019 \uc138\ub300\uc5d0\uc11c\uc758 \ud574\uc81c (deallocation) \ube44\uc6a9\uc740 \u20180\u2032 \ub2e4. \ub9c8\uce58 \ud658\ud615 \ud050\uc5d0\uc11c \uc774\ubbf8 \uaebc\ub0b8 \ub370\uc774\ud130\uc758 \ucc38\uc870\ub97c \uc9c0\uc6b0\uc9c0 \uc54a\uc558\ub2e4\uac00 \ub098\uc911\uc5d0 \ub2e8\uc21c\ud788 \ub36e\uc5b4 \uc50c\uc6b0\ub294 \uac83\uc5d0 \ube44\uc720\ud560 \uc218 \uc788\ub2e4.<\/p>\n\n\n\n
\uc81c\uc784\uc2a4 \uace0\uc2ac\ub9c1\uc758 \uc77c\ud654<\/h3>\n\n\n\n
-server<\/code> \uc635\uc158\ub9cc\uc73c\ub85c\ub3c4 GCC \ub85c \ucda9\ubd84\ud788 \ucd5c\uc801\ud654\ub41c C\/C++ \uc5b4\ud50c\ub9ac\ucf00\uc774\uc158\uc5d0 \ud544\uc801\ud55c \uc131\ub2a5\uc774 \ub098\uc628\ub2e4\ub294 \uc774\uc57c\uae30\uc785\ub2c8\ub2e4.<\/p>\n\n\n\n
\n