You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/11/28 17:36:50 UTC

[GitHub] davisp opened a new issue #1772: Slow operation in couch_proc_manager

davisp opened a new issue #1772: Slow operation in couch_proc_manager
URL: https://github.com/apache/couchdb/issues/1772
 
 
   We've noticed a couple couch_proc_manager backups when deploying the latest version. Inspecting code I ended up stumbling over the new config code. Its theoretically quite a bit slower than the old code since its doing OS env checking but its also doing things quite inefficiently beyond that.
   
   https://github.com/apache/couchdb/blob/master/src/couch/src/couch_proc_manager.erl#L375-L383
   
   The three big things to notice here are that we're joining the variable names inside the loop which is a bit wasteful. Given the size of the strings I'm not sure how bad that is though. I'd wager it likely depends on how many environment variables there are to know whether its making a difference. The tokens call with a pattern match also seems like an expensive thing to be doing. However the killer bit is probably that we're looping over `os:getenv()` every time we create a new process which is likely what's caused the backups.
   
   I'd propose two changes. The first simpler of the two is to just create our expected environment variable and use `os:getenv/1`.
   
   Something like:
   
   ```erlang
   get_env_for_spec(Spec, Target) ->
       SpecStr = Spec ++ Target,
       os:getenv(SpecStr, undefined).
   ```
   
   We're still going to be hitting `os:getenv/1` every time we create a new process though so I'd also recommend caching succcessful finds in an ets table or similar. That would allow us to have similar speed to before the patch while still maintaining the OS env config approach.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services