← Back to team overview

yade-dev team mailing list archive

Re: [Branch ~yade-pkg/yade/git-trunk] Rev 3888: Use unordered_map instead of map for MapId2IntrT

 

Hi Bruno,

what I have learned is that unordered_map is usually faster than map,
but takes some more memory in compare to simple map.

If we consider an overall Yade performance, one can see that on a small
simulations (<20k particles), the performance decreases a little bit,
and on large simulations it increases.

I will probably revert this change.

Thanks for this notice.

Anton


2016-06-08 10:11 GMT+02:00 Bruno Chareyre <bruno.chareyre@xxxxxxxxxxxxxxx>:
> Hi Anton,
> Interesting change, did you benchmark it?
> I see insertion, deletion, find, all have different costs. Since the number
> of interaction per body is typically low I wonder how the nominal costs
> apply.
> Bruno
>
> On 7 June 2016 at 23:46, <noreply@xxxxxxxxxxxxx> wrote:
>>
>> ------------------------------------------------------------
>> revno: 3888
>> committer: Anton Gladky <gladky.anton@xxxxxxxxx>
>> timestamp: Tue 2016-06-07 20:48:04 +0200
>> message:
>>   Use unordered_map instead of map for MapId2IntrT
>>
>>   find() function should search there in O(1) time
>>   instead of O(lg(n))
>> modified:
>>   core/Body.hpp
>>   lib/multimethods/FunctorWrapper.hpp
>>
>>
>> --
>> lp:yade
>> https://code.launchpad.net/~yade-pkg/yade/git-trunk
>>
>> Your team Yade developers is subscribed to branch lp:yade.
>> To unsubscribe from this branch go to
>> https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
>>
>> === modified file 'core/Body.hpp'
>> --- core/Body.hpp       2016-06-02 18:06:44 +0000
>> +++ core/Body.hpp       2016-06-07 18:48:04 +0000
>> @@ -14,6 +14,9 @@
>>  #include "State.hpp"
>>  #include "Material.hpp"
>>
>> +#include <unordered_map>
>> +#include <boost/serialization/unordered_map.hpp>
>> +
>>  #include <lib/base/Math.hpp>
>>  #include <lib/serialization/Serializable.hpp>
>>  #include <lib/multimethods/Indexable.hpp>
>> @@ -26,7 +29,7 @@
>>                 // numerical types for storing ids
>>                 using id_t = int ;
>>                 // internal structure to hold some interaction of a body;
>> used by InteractionContainer;
>> -               using MapId2IntrT = std::map<Body::id_t,
>> shared_ptr<Interaction> >;
>> +               using MapId2IntrT = std::unordered_map<Body::id_t,
>> shared_ptr<Interaction> >;
>>                 // groupMask type
>>
>>                 // bits for Body::flags
>>
>> === modified file 'lib/multimethods/FunctorWrapper.hpp'
>> --- lib/multimethods/FunctorWrapper.hpp 2015-11-09 20:26:06 +0000
>> +++ lib/multimethods/FunctorWrapper.hpp 2016-06-07 18:48:04 +0000
>> @@ -97,7 +97,6 @@
>>  {
>>         private :
>>                 typedef Loki::FunctorImpl<ResultType, ArgumentTypeList >
>> Impl;
>> -               typedef ArgumentTypeList ParmList;
>>                 typedef typename Impl::Parm1 Parm1;
>>                 typedef typename Impl::Parm2 Parm2;
>>                 typedef typename Impl::Parm3 Parm3;
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~yade-dev
>> Post to     : yade-dev@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~yade-dev
>> More help   : https://help.launchpad.net/ListHelp
>>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-dev
> Post to     : yade-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-dev
> More help   : https://help.launchpad.net/ListHelp
>


References