globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 230 forks source link

mgo/dbtest: Set wiredTiger cache size so that it does not default to 50% RAM #265

Closed timvaillancourt closed 6 years ago

timvaillancourt commented 6 years ago

By default wiredTiger will set it's cache size to 50% of the available RAM, even when inside docker, cgroups, etc.

This PR changes wiredTiger to use only 100MB of RAM for cache (0.1GB) in tests.

eminano commented 6 years ago

Hi @timvaillancourt,

Thanks for your PR. I think if you're trying to fix the arbitrary default value for the cache size you should make it so it's configurable instead of setting it to a default value that suits your case but might not be ok for others.

Could you please adapt this so it's not hardcoded but can be set on the dbtest object?

Thanks, Esther

timvaillancourt commented 6 years ago

Good idea @eminano. I'll add a func for this.

As dbtest tunes MMAPv1 to use no journaling and less resources https://github.com/globalsign/mgo/blob/a5c1b0da7944e82d2e3ae2fbcae642df96f60445/dbtest/dbserver.go#L86-L90 I think it makes sense to use 100mb/0.1GB as the default sizing, but a func will allow this to be overridden if you want more cache.

eminano commented 6 years ago

Thanks for another contribution @timvaillancourt!