[complement-svn] SF.net SVN: complement: [1766] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2007-10-16 08:03:31
|
Revision: 1766 http://complement.svn.sourceforge.net/complement/?rev=1766&view=rev Author: complement Date: 2007-10-16 01:03:28 -0700 (Tue, 16 Oct 2007) Log Message: ----------- use hash instead of map, this save ~10 bytes per stem object; in gaddr_type structure use 32-bit integer for pid, most systems has max(pid) < 2^15, 64-bit Linuxes max(pid) < 4*1024*1024, but some other unixes may has larger numbers... check it; this save ~24 bytes per stem object; libstem: library version 4.7.0 Modified Paths: -------------- trunk/complement/explore/include/janus/vtime.h trunk/complement/explore/include/stem/EvManager.h trunk/complement/explore/include/stem/Event.h trunk/complement/explore/lib/stem/ChangeLog trunk/complement/explore/lib/stem/EvPack.cc trunk/complement/explore/lib/stem/Makefile.inc Modified: trunk/complement/explore/include/janus/vtime.h =================================================================== --- trunk/complement/explore/include/janus/vtime.h 2007-10-09 13:14:54 UTC (rev 1765) +++ trunk/complement/explore/include/janus/vtime.h 2007-10-16 08:03:28 UTC (rev 1766) @@ -6,6 +6,16 @@ #include <algorithm> #include <list> #include <vector> +#include <iterator> +#include <istream> +#include <ostream> +#include <stdexcept> + +#include <stem/Event.h> +#include <stem/EventHandler.h> + +#include <mt/time.h> + #ifdef STLPORT # include <unordered_map> # include <unordered_set> @@ -24,16 +34,8 @@ # define __USE_STD_TR1 # endif #endif -#include <iterator> -#include <istream> -#include <ostream> -#include <stdexcept> -#include <stem/Event.h> -#include <stem/EventHandler.h> -#include <mt/time.h> - namespace janus { // typedef stem::addr_type oid_type; @@ -41,6 +43,7 @@ } // namespace janus +#if 0 #if defined(__USE_STLPORT_HASH) || defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) # define __HASH_NAMESPACE std #endif @@ -68,6 +71,7 @@ } // namespace __HASH_NAMESPACE #undef __HASH_NAMESPACE +#endif namespace janus { Modified: trunk/complement/explore/include/stem/EvManager.h =================================================================== --- trunk/complement/explore/include/stem/EvManager.h 2007-10-09 13:14:54 UTC (rev 1765) +++ trunk/complement/explore/include/stem/EvManager.h 2007-10-16 08:03:28 UTC (rev 1766) @@ -21,7 +21,7 @@ #include <stdint.h> #include <string> -#include <map> +// #include <map> #include <deque> #include <mt/xmt.h> @@ -31,6 +31,25 @@ #include <stem/EventHandler.h> #include <ostream> +#ifdef STLPORT +# include <unordered_map> +# include <unordered_set> +// # include <hash_map> +// # include <hash_set> +// # define __USE_STLPORT_HASH +# define __USE_STLPORT_TR1 +#else +# if defined(__GNUC__) && (__GNUC__ < 4) +# include <ext/hash_map> +# include <ext/hash_set> +# define __USE_STD_HASH +# else +# include <tr1/unordered_map> +# include <tr1/unordered_set> +# define __USE_STD_TR1 +# endif +#endif + namespace stem { namespace detail { @@ -76,6 +95,35 @@ class EvManager { private: +#ifdef __USE_STLPORT_HASH + typedef std::hash_map<addr_type,EventHandler *> local_heap_type; + typedef std::hash_map<addr_type,std::string> info_heap_type; + + typedef std::hash_map<addr_type,gaddr_type> ext_uuid_heap_type; + + typedef std::hash_multimap<gaddr_type,std::pair<addr_type,detail::transport> > uuid_tr_heap_type; + typedef std::hash_multimap<detail::transport_entry,gaddr_type> tr_uuid_heap_type; +#endif +#ifdef __USE_STD_HASH + typedef __gnu_cxx::hash_map<addr_type,EventHandler *> local_heap_type; + typedef __gnu_cxx::hash_map<addr_type,std::string> info_heap_type; + + typedef __gnu_cxx::hash_map<addr_type,gaddr_type> ext_uuid_heap_type; + + typedef __gnu_cxx::hash_multimap<gaddr_type,std::pair<addr_type,detail::transport> > uuid_tr_heap_type; + typedef __gnu_cxx::hash_multimap<detail::transport_entry,gaddr_type> tr_uuid_heap_type; +#endif +#if defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) + typedef std::tr1::unordered_map<addr_type,EventHandler *> local_heap_type; + typedef std::tr1::unordered_map<addr_type,std::string> info_heap_type; + + typedef std::tr1::unordered_map<addr_type,gaddr_type> ext_uuid_heap_type; + + typedef std::tr1::unordered_multimap<gaddr_type,std::pair<addr_type,detail::transport> > uuid_tr_heap_type; + typedef std::tr1::unordered_multimap<detail::transport_entry,gaddr_type> tr_uuid_heap_type; +#endif + +#if 0 typedef std::map<addr_type,EventHandler *> local_heap_type; typedef std::map<addr_type,std::string> info_heap_type; @@ -83,6 +131,7 @@ typedef std::multimap<gaddr_type,std::pair<addr_type,detail::transport> > uuid_tr_heap_type; typedef std::multimap<detail::transport_entry,gaddr_type> tr_uuid_heap_type; +#endif static bool tr_compare( const std::pair<gaddr_type,std::pair<addr_type,detail::transport> >& l, const std::pair<gaddr_type,std::pair<addr_type,detail::transport> >& r ) { return l.second.second < r.second.second; } @@ -268,4 +317,17 @@ } // namespace stem +#ifdef __USE_STLPORT_HASH +# undef __USE_STLPORT_HASH +#endif +#ifdef __USE_STD_HASH +# undef __USE_STD_HASH +#endif +#ifdef __USE_STLPORT_TR1 +# undef __USE_STLPORT_TR1 +#endif +#ifdef __USE_STD_TR1 +# undef __USE_STD_TR1 +#endif + #endif // __stem_EvManager_h Modified: trunk/complement/explore/include/stem/Event.h =================================================================== --- trunk/complement/explore/include/stem/Event.h 2007-10-09 13:14:54 UTC (rev 1765) +++ trunk/complement/explore/include/stem/Event.h 2007-10-16 08:03:28 UTC (rev 1766) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/17 22:15:41 ptr> +// -*- C++ -*- Time-stamp: <07/10/15 22:41:17 ptr> /* * @@ -31,6 +31,25 @@ #include <mt/uid.h> #include <mt/xmt.h> +#ifdef STLPORT +# include <unordered_map> +# include <unordered_set> +// # include <hash_map> +// # include <hash_set> +// # define __USE_STLPORT_HASH +# define __USE_STLPORT_TR1 +#else +# if defined(__GNUC__) && (__GNUC__ < 4) +# include <ext/hash_map> +# include <ext/hash_set> +# define __USE_STD_HASH +# else +# include <tr1/unordered_map> +# include <tr1/unordered_set> +# define __USE_STD_TR1 +# endif +#endif + namespace stem { typedef uint32_t addr_type; @@ -77,7 +96,10 @@ { } xmt::uuid_type hid; - int64_t pid; // pid_t defined as int, so it may be int64_t + // int64_t pid; // pid_t defined as int, so it may be int64_t + // most systems has max(pid) < 2^15, 64-bit Linuxes max(pid) < 4 *1024 *1024 + // but some other unixes may has larger numbers... check it + uint32_t pid; stem::addr_type addr; __FIT_DECLSPEC virtual void pack( std::ostream& ) const; @@ -618,4 +640,45 @@ namespace EDS = stem; +#if defined(__USE_STLPORT_HASH) || defined(__USE_STLPORT_TR1) || defined(__USE_STD_TR1) +# define __HASH_NAMESPACE std #endif +#if defined(__USE_STD_HASH) +# define __HASH_NAMESPACE __gnu_cxx +#endif + +namespace __HASH_NAMESPACE { + +#ifdef __USE_STD_TR1 +namespace tr1 { +#endif + +template <> +struct hash<stem::gaddr_type> +{ + size_t operator()(const stem::gaddr_type& __x) const + { return __x.addr | (__x.pid << 23); } +}; + +#ifdef __USE_STD_TR1 +} +#endif + +} // namespace __HASH_NAMESPACE + +#undef __HASH_NAMESPACE + +#ifdef __USE_STLPORT_HASH +# undef __USE_STLPORT_HASH +#endif +#ifdef __USE_STD_HASH +# undef __USE_STD_HASH +#endif +#ifdef __USE_STLPORT_TR1 +# undef __USE_STLPORT_TR1 +#endif +#ifdef __USE_STD_TR1 +# undef __USE_STD_TR1 +#endif + +#endif // __stem_Event_h Modified: trunk/complement/explore/lib/stem/ChangeLog =================================================================== --- trunk/complement/explore/lib/stem/ChangeLog 2007-10-09 13:14:54 UTC (rev 1765) +++ trunk/complement/explore/lib/stem/ChangeLog 2007-10-16 08:03:28 UTC (rev 1766) @@ -1,3 +1,16 @@ +2007-10-16 Petr Ovtchenkov <pt...@is...> + + * Event.h, EvManager.h: use hash instead of map, this save + ~10 bytes per stem object; + + * Event.h, EvPack.cc: in gaddr_type structure use 32-bit + integer for pid, most systems has max(pid) < 2^15, 64-bit + Linuxes max(pid) < 4*1024*1024, but some other unixes may + has larger numbers... check it; this save ~24 bytes per + stem object; + + * libstem: library version 4.7.0 + 2007-10-09 Petr Ovtchenkov <pt...@is...> * EventHandler.h: preserve and restore format flags during Modified: trunk/complement/explore/lib/stem/EvPack.cc =================================================================== --- trunk/complement/explore/lib/stem/EvPack.cc 2007-10-09 13:14:54 UTC (rev 1765) +++ trunk/complement/explore/lib/stem/EvPack.cc 2007-10-16 08:03:28 UTC (rev 1766) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <07/08/03 09:22:05 ptr> +// -*- C++ -*- Time-stamp: <07/10/15 22:35:41 ptr> /* * Copyright (c) 1997-1999, 2002, 2003, 2005, 2006 @@ -143,7 +143,7 @@ __FIT_DECLSPEC void gaddr_type::_xnet_pack( char *buf ) const { - uint64_t _pid = to_net( pid ); + /* uint64_t */ uint32_t _pid = to_net( pid ); addr_type _addr = to_net( addr ); // copy( (char *)hid.u.b, (char *)hid.u.b + 16, buf ); Modified: trunk/complement/explore/lib/stem/Makefile.inc =================================================================== --- trunk/complement/explore/lib/stem/Makefile.inc 2007-10-09 13:14:54 UTC (rev 1765) +++ trunk/complement/explore/lib/stem/Makefile.inc 2007-10-16 08:03:28 UTC (rev 1766) @@ -2,8 +2,8 @@ LIBNAME = stem MAJOR = 4 -MINOR = 6 -PATCH = 5 +MINOR = 7 +PATCH = 0 SRC_CC = _EventHandler.cc NetTransport.cc EvManager.cc EvPack.cc crc.cc \ Names.cc Cron.cc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |