Editing User:Pulkit Mittal/GSOC2014/logs

From BRL-CAD

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 17: Line 17:
 
*Thread Safety in cllazyfile ''Status'': Review Awaiting  
 
*Thread Safety in cllazyfile ''Status'': Review Awaiting  
 
*Thread Safety in clstepcore ''Status'': Review Awaiting
 
*Thread Safety in clstepcore ''Status'': Review Awaiting
*Thread Safety in cleditor ''Status'': Review Awaiting
+
*Thread Safety in cleditor ''Status'': Started
*Thread Safety in cldai ''Status'': Review Awaiting
+
*Thread Safety in cldai ''Status'': Not Started
 +
*Introduce multi-threading cllazyfile ''Status'': Not Started
  
 
===Bonus===
 
===Bonus===
In this section I will list down all other modifications which I did during the GSOC period.
+
In this section I will list down all the single threaded performance optimizations which are done in the GSOC period.
* Single threaded performance optimizations
+
 
** Removed ''istream *in2'' from ''STEPfile::AppendFile''. Originally for the second pass a new ''istream (in2)'' was being created and the ''.step'' file was being opened again. This was prevented by directing the original ''istream (in)'' to the beggining of the ''.step'' file.
 
* Code Refractoring
 
** In libraries clstepcore and cldai, there were few classes which were very similar. The logic common to these classes was indentified and removed, a new class was created which had that common logic. The original classes were made to inherit from the new class. This removed duplicated code and also made making changes (for thread safety) easier.
 
  
  
Line 490: Line 488:
 
*** This could have ruined the thread safe strategy for making ''EntList'' thread safe. (violated our assumption)
 
*** This could have ruined the thread safe strategy for making ''EntList'' thread safe. (violated our assumption)
 
*** The reason it didn't was that, that ''EntList'' was created locally.
 
*** The reason it didn't was that, that ''EntList'' was created locally.
 +
* Work done from 24 July was organized into commits and pushed to github.
  
 
'''3 August (Sun)'''
 
'''3 August (Sun)'''
* Work done from 24 July was organized into commits and pushed to github.
 
* Made ''ReplicateList'' in ''cleditor'' thread safe.
 
** Used ''mtxP'' of the superclass ''SingleLinkList'' to ensure thread safety
 
* Thread safety in ''CmdMgr'' of ''cleditor''
 
 
'''4 August (Mon)'''
 
* Not much work done as it was a heavy day in college
 
 
'''5 August (Tue)'''
 
* Made ''DirObj'' of ''clutils'' thread safe.
 
** This was achieved introducing a mutex in the ''DirObj'' class.
 
** Course-Level (fat) Locking was done only in publically accessed function.
 
 
'''6 August (Wed)'''
 
* Work done from 3 August was organized into commits and pushed to github.
 
 
'''7 August (Thu)'''
 
* Converted ''GetKeyword'' to ''FillKeyword''.
 
** In the original function a ''static string'' was being used.
 
** The dependency on the static string was removed by passing a string as a parameter from the caller to callee, so that the function could operate without worrying about thread safety.
 
** The function name change mimics the change in the semantics of the function.
 
** The various callers were modified to incorperate this change
 
 
'''8 August (Fri)'''
 
* Optimized ''ReadReal''. Replaced calls to input stream peek & get with judicious use of get.
 
* Work done from 7 August was organized into commits and pushed to github.
 
 
 
 
=== Week 13 ===
 
'''9 August (Sat)'''
 
* No changes were done to ''Sdai*'' files of the ''cleditor'' library as those files were generated by ''exp2cxx''.
 
** Any modifications would be lost if ''exp2cxx'' was used to regenerate them.
 
* Went through ''STEPfile'' class to determine the areas of thread safety violations.
 
 
'''10 August (Sun)'''
 
* Inspired by a comment written by a developer, removed ''istream *in2'' from ''STEPfile::AppendFile''.
 
** Originally for the second pass a new ''istream (in2)'' was being created and the ''.step'' file was being opened again.
 
** The above was prevented by directing the original istream (in) to the beggining of the ''.step'' file.
 
** The work was commited and pushed into github.
 
 
'''11 August (Mon)'''
 
* Protected ''_headerId'' in ''STEPfile'' ''(cleditor)''.
 
** ''_headerId'' is a counter used in ''STEPfile'' class.
 
** Its value could change in ''ReadHeader'' and ''ReadExchangeFile'' methods.
 
** Hence a mutex was introduced specially to protect it.
 
* Added ''GetApplication_instanceFromFileId'' method in ''InstMgr'' class.
 
** The ''SDAI_Application_instance * GetApplication_instance( MgrNode * )'' and'' MgrNode * FindFileId( int )'' methods of class ''InstMgr'' were often being used together in the class ''STEPfile''.
 
** Therefore a special function was created in class ''InstMgr'' of the form ''SDAI_Application_instance * GetApplication_instanceFromFileId( int )'' which would take care of locking and consistency issues.
 
** This function was then used in ''STEPfile''.
 
 
'''12 August (Tue)'''
 
* Safe ''InstMgr'' iteration in ''STEPfile''.
 
** Variables of class ''InstMgr'' were being iterated upon in class ''STEPfile'' through the variables ''_instances'' (including its get function ''instances()'') and ''_headerInstances''.
 
** The mtx defined in ''InstMgr'' was invoked to make them safe.
 
 
'''13 August (Wed)'''
 
* Safe ''attributes'' iteration in ''STEPfile''.
 
** This was done by using mutexes defined for ''SDAI_Application_instance'' & ''SingleLinkList'' classes.
 
* It was decided that as this class acts like a parser, further locking in this class would be dependent upon how it will be used in a multithreaded way.
 
** The current structure of the class was restricting any potential multithreaded use.
 
** Example: The variable like ''_fileName'' restricts this class to parse only one file at a time. If we want to parse more then one then this would have to change.
 
* Thread safety in ''SDAI_Application_instance__set''
 
** This was done by introducing a ''recursive_mutex'' in the ''SDAI_Application_instance__set'' class.
 
* Work done from 11 August was organized into commits and pushed to github.
 
 
'''14 Augest (Thu)'''
 
* Removed compile time warning from the previous day commit.
 
* Added class ''SDAI__set'' in ''cldai'' library
 
** It was noticed that some classes in this library which were very similar: ''SDAI_DAObject__set'', ''SDAI_Entity_extent__set'' & ''SDAI_Model_contents__list''
 
** The logic common to these classes was indentified and removed, a new class (''SDAI__set'') was created which had that common logic.
 
** The original classes were made to inherit from the new class.
 
** This removed duplicated code and also made making changes (for thread safety) easier.
 
* Made ''SDAI__set'' thread safe
 
** This was done by introducing a mutex in the ''SDAI__set'' class.
 
 
'''15 Augest (Fri)'''
 
* Added ''SDAI__set::Remove( SDAI_ptr )'' function
 
** The semantics of this function would be similar to ''SDAI__set::Remove( SDAI__set::Index( SDAI_ptr ) )''. The only difference would be that in the new function both the operations are done under a single lock.
 
** Wherever the old ''Remove( Index( SDAI_ptr ) )'' code snippet was found, it was replaced by the new ''Remove( SDAI_ptr )'' function.
 
* One more subclass of ''SDAI__set''
 
** Adding the ''Remove( SDAI_ptr )'' API to ''SDAI__set'' made ''SDAI_Application_instance__set'' a candidate for inheriting common logic from ''SDAI__set''.
 
** Note: This class was already made thread safe in one of the previous commits. This commit only removes the now apparent duplicate code.
 
* Work done from 14 August was organized into commits and pushed to github.
 
 
 
 
=== Week 14 ===
 
'''16 Augest (Sat)'''
 
* On the advice of ''starseeker'' I decided to perform the ''acid test'' by running my version of stepcode through ''step-g'' converter.
 
** Set up ''brlcad''.
 
** Ran ''step-g'' converter on a sample ap203 file.
 
 
'''17 Augest (Sun)'''
 
* Tried to run ''step-g'' using my stepcode version. Unfortunately I was not successful partially due to the following reasons.
 
** To start with, a lot of time was wasted, identifying the CMake file in brlcad in which I should set ''CMAKE_CXX_FLAGS'' (or equivalent) with ''-std=c++0x'' so as to run my version of stepcode which uses ''std::mutex'' & ''std::thread''
 
** Secondly apart from the changes I did in stepcode through ''hj/thread-safety'' branch the stepcode version in ''brlcad/src/other/stepcode'' had many differences.
 
*** It initially gave many build errors.
 
*** When it finally ran it gave a seg-fault on the piece of code I have never changed.
 
* Added ''NO_REGISTRY'' macro to ''lazy_thread_safety_test''
 
** ''lazy_thread_safety_test'' had 2 checks which were schema dependent. These checks are now wrapped in ''NO_REGISTRY'' macro.
 
 
'''18 Augest (Mon)'''
 
* Utilized ''sc_mutex'' in ''cllazyfile''
 
** Earlier ''std::mutex'' was being used.
 
** It was replaced with ''sc_mutex'' which acts like a wrapper to ''std::mutex''.
 
* Added ''sc_thread.h'' in ''clutils''
 
** The class acts like a wrapper to some of the thread functionalities (like ''get_id()'') which is being used in stepcode.
 
** If the compiler does not supports thread functionalities then this class provides dummy types and functionalities.
 
** ''instMgrAdapter'' & ''lazyTypes.h'' were modified so as to take dependency on ''sc_thread''.
 
* As a result of above two changes ''HAVE_STD_THREAD'' macros were removed from cllazyfile library *.cc and *.h as classes ''sc_thread'' and ''sc_mutex'' internally handles the macros.
 
* Added exit(success/fail) in thread-safety test
 
* Organized the work done from 17 augest into commits and pushed into github
 
* Merged remote-tracking branch ''origin/master'' into ''hj/thread-safety''
 
** As I had never merged the master branch into the branch I was working upon ever since I started working on this project, I was 109 commits ahead and 23 commits behind the master branch.
 
** I merged those the 23 commits into my ''hj/thread-safety'' branch. The only conflict was in ''src/clstepcore/instMgr.cc'' which was handled by me.
 

Please note that all contributions to BRL-CAD may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see BRL-CAD:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)