OMNeT++/OMNEST Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000022OMNeT++simulation kernelpublic2008-12-05 16:112009-07-25 17:38
Assigned Toandras 
PlatformOSOS Version
Product Version4.0b8 
Target VersionFixed in Version4.1 
Summary0000022: Perfomance issue: cMessage::getArrivalTime() returns simtime_t by value
DescriptioncMessage::getArrivalTime() returns simtime_t by value. This is a performance problem especially for the FES (shiftup and insert).

After changing the method to return const simtime_t& we had performance improvements of about 10-20 percent (compiled with -O3).

Probably this should be changed for all simtime_t setters and getters in cmessage.h.
TagsNo tags attached.
Attached Filesdiff file icon simtime_by_reference.diff [^] (941 bytes) 2009-03-10 12:03 [Show Content]

- Relationships

-  Notes
andras (administrator)
2009-07-25 13:22
edited on: 2009-07-25 13:24

I did some measurements as well, with interesting results.

cqn example (100 tandems, 50 queues/tandem), cmdenv express mode, ubuntu 32-bit, g++ 4.3.2.

In debug mode (make MODE=debug), I saw the performance hit you described (~ 15-20% spent in getArrivalTime()).

In release builds (-O2), this difference disappeared:

  real 0m15.372s
  user 0m10.257s
  sys 0m0.144s

  real 0m15.377s
  user 0m10.193s
  sys 0m0.124s

kcachegrind runs showed similar results (difference was only ~0.2%).

Still, going on with the change looks like a good idea, because debug builds benefit a lot.

It is an interesting question how this would affect performance on 64-bit architectures, where a SimTime object fits into a single machine register. There, returning a reference (which is actually a pointer) instead of the value might be a performance penalty. I did not make measurements in this direction yet. However, today most users are still on 32-bit architectures, so the change would benefit them.

andras (administrator)
2009-07-25 17:38

Introduced simtime_t_retval which is a typedef for const simtime_t&, and changed cMessage method return types to that. Via simtime_t_retval, it will be easy to turn off this optimization when it adversely affects performance (i.e. 64-bit optimized builds)

- Issue History
Date Modified Username Field Change
2008-12-05 16:11 baumgart New Issue
2009-03-10 12:03 baumgart File Added: simtime_by_reference.diff
2009-07-25 13:22 andras Note Added: 0000160
2009-07-25 13:23 andras Assigned To => andras
2009-07-25 13:23 andras Status new => in work
2009-07-25 13:24 andras Note Edited: 0000160
2009-07-25 17:38 andras Note Added: 0000161
2009-07-25 17:38 andras Status in work => resolved
2009-07-25 17:38 andras Fixed in Version => 4.1
2009-07-25 17:38 andras Resolution open => fixed

Copyright © 2000 - 2022 MantisBT Team
Powered by Mantis Bugtracker