
Hello, Some time ago there was a discussion about flyweight library, I have examined it and considered it very useful. Especially now, it is possible that I will need to use it. Since I cannot find it either inisde CVS nor in boost sandbox, I wanted to ask what is the status of flywieght library? - is it yet to be submitted as a library proposal ? - it has been already accepted and will be Added Soon (tm) to CVS ? - something else ... ? -- Janek Kozicki |

Hello Janek, ----- Mensaje original ----- De: Janek Kozicki <janek_listy@wp.pl> Fecha: Jueves, Octubre 5, 2006 9:20 pm Asunto: [boost] flyweight library? Para: boost@lists.boost.org
Hello,
Some time ago there was a discussion about flyweight library, I have examined it and considered it very useful. Especially now, it is possible that I will need to use it.
Since I cannot find it either inisde CVS nor in boost sandbox, I wantedto ask what is the status of flywieght library?
- is it yet to be submitted as a library proposal ?
This is my plan.
- it has been already accepted and will be Added Soon (tm) to CVS ?
No, not at all.
- something else ... ?
After uploading the version of the lib you can find at the vault, I've continued evolving it to make it more customizable, include serialization support and some other goodies. The basic code base is set up, but there's still quite some work to do before I can present it in public, and, if acceptance is good, request a formal review. I'd say the stuff could be ready for presentation around Dec 06 or Jan 07.
-- Janek Kozicki
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

JOAQUIN LOPEZ MU?Z said: (by the date of Thu, 05 Oct 2006 22:53:10 +0200)
After uploading the version of the lib you can find at the vault. I'd say the stuff could be ready for presentation around Dec 06 or Jan 07.
thanks for your answer. I'll get it from the vault and examine it carefully, while trying to use it. I see a possibility to save a lot of memory :) If I decide to depend on it, I hope that it will make its way into boost 1.35 :) -- Janek Kozicki |

Janek Kozicki ha escrito:
JOAQUIN LOPEZ MU?Z said: (by the date of Thu, 05 Oct 2006 22:53:10 +0200)
After uploading the version of the lib you can find at the vault. I'd say the stuff could be ready for presentation around Dec 06 or Jan 07.
thanks for your answer.
You're welcome.
I'll get it from the vault and examine it carefully, while trying to use it. I see a possibility to save a lot of memory :) If I decide to depend on it, I hope that it will make its way into boost 1.35 :)
What is your intended usage scenario? It might help me add more diversity to the examples section of the lib. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Joaquín M_ López Mu_oz said: (by the date of Fri, 06 Oct 2006 07:48:22 +0200)
Janek Kozicki ha escrito:
What is your intended usage scenario? It might help me add more diversity to the examples section of the lib.
1. I want to try to use it together with boost::serialization when converting between archive formats. Think about xml format - it has to remember variable name (as a string) for each variable. But with large collections, those strings are higly duplicated. Like - a container with 1000 similar objects that have just 8 variables. And of course those variables have long names, because the names should be descriptive :) 2. a Typo in libs/flyweight/doc/tutorial/holders.html: "For instance, flyweight<T> is equivalent to" ^^^ 3. am I right to think that: flyweight<std::string,hashed_factory<>,global_holder<unsigned char> > will allow me to have 255 different strings, while flyweight<std::string,hashed_factory<>,global_holder<unsigned short> > will allow me to have 65535 ? 4. have you ever thought about sample usage of flywieght to create a new boost library: boost::flyweight_shared_ptr<T> ? The problem it tries to solve is that on amd64 each pointer consumes 64 bits (8 bytes!), when people make a switch from 32bits to 64bits, this hurts badly. In my calculations memory usage grew from 700MB to 1.3GB, and that actually makes a difference. (it's not possible to run calculations if some of the data must swap to disc...) hmm... maybe this will actually work: boost::flyweight<boost::shared_ptr<T> > will it? -- Janek Kozicki |

----- Mensaje original ----- De: Janek Kozicki <janek_listy@wp.pl> Fecha: Domingo, Octubre 8, 2006 0:12 am Asunto: Re: [boost] flyweight library? Para: boost@lists.boost.org > Joaquín M_ López Mu_oz said: (by the date of Fri, 06 Oct 2006 > 07:48:22 +0200) > > > Janek Kozicki ha escrito: > 2. a Typo in libs/flyweight/doc/tutorial/holders.html: > > "For instance, flyweight<T> is equivalent to" > ^^^ Thank you, will fix it. > 3. am I right to think that: > > flyweight<std::string,hashed_factory<>,global_holder<unsigned > char> > > > will allow me to have 255 different strings, while > > flyweight<std::string,hashed_factory<>,global_holder<unsigned > short> > > > will allow me to have 65535 ? Emm, no, that's not correct. The holder is used to maintain a unique copy of the flyweight factory, its role is very similar to that of a singleton. Nothing to do with controlling the capacity of the factory. > > > 4. have you ever thought about sample usage of flywieght to create > a new > boost library: boost::flyweight_shared_ptr<T> ? > > The problem it tries to solve is that on amd64 each pointer > consumes 64 > bits (8 bytes!), when people make a switch from 32bits to 64bits, this > hurts badly. In my calculations memory usage grew from 700MB to 1.3GB, > and that actually makes a difference. (it's not possible to run > calculations if some of the data must swap to disc...) > > hmm... maybe this will actually work: > > boost::flyweight<boost::shared_ptr<T> > > > will it? Well, the short answer is that flyweight won't gain you nothing wrt to shared_ptr, since flyweight objects contain a pointer (much like shared_ptr's) which is 8 bytes in 64bit architectures. The long answer is, given the flexibility that the componentized nature of flyweight allows, it is possible to devise a factory adaptor that limits the capacity of the factory *and* let the flyweight object use internally a handle value smaller in size than a pointer (an index of size unsigned short, for instance). I will try to write something along this line, I'll keep you informed. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

JOAQUIN LOPEZ MU?Z said: (by the date of Sun, 08 Oct 2006 13:21:04 +0200)
Well, the short answer is that flyweight won't gain you nothing wrt to shared_ptr, since flyweight objects contain a pointer (much like shared_ptr's) which is 8 bytes in 64bit architectures. The long answer is, given the flexibility that the componentized nature of flyweight allows, it is possible to devise a factory adaptor that limits the capacity of the factory *and* let the flyweight object use internally a handle value smaller in size than a pointer (an index of size unsigned short, for instance). I will try to write something along this line, I'll keep you informed.
many thanks. This is the feature I'm looking for. Consider my first example about serialization. The variable names in classess have names with various length, eg: "foo", "bar", "my_cool_foo_bar_controller", etc. Their length varies, but in some cases average length is shorter than 8 characters (64 bits), therefore only this size reduction (8 bytes -> 1 byte) gives an improvement. In the case of std::string("foo"); we actually lose 5 bytes of memory on amd64 with flyweight (minus some additional storage data that std::string might use..) ;) -- Janek Kozicki |
participants (4)
-
"JOAQUIN LOPEZ MU?Z"
-
Chandrashekhar Kumar
-
Janek Kozicki
-
Joaquín Mª López Muñoz