Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDbHttpSession: garbage collection probability cannot be set low enough #486

Closed
tom-- opened this issue Mar 11, 2012 · 12 comments
Closed

CDbHttpSession: garbage collection probability cannot be set low enough #486

tom-- opened this issue Mar 11, 2012 · 12 comments
Assignees
Milestone

Comments

@tom--
Copy link
Contributor

tom-- commented Mar 11, 2012

CDbHttpSession's configuration allows a minimum GC probability of 1%.

if a server is handling, e.g., 1000 requests a second, that means it runs GC 10 times a second. that's wasteful. in many cases once a minute would be sufficient so this minimum constraint could be off by two or three orders of magnitude.

suggest allowing the configuration of PHP's GC denominator.

@resurtm
Copy link
Contributor

resurtm commented Aug 25, 2012

@tom-- Could you please help with process of testing patch provided in PR #1288?

@tom--
Copy link
Contributor Author

tom-- commented Aug 25, 2012

Hi,

Thanks for doing this. Using a float is a great idea. Should be tolerable backwards compat. I will be glad to try to test but I have a couple of suggestions first.

First, bumping the divisor up to 100000 seems a little arbitrary to me. If Yii offers the user a float for $gCProbability, why not allow as much range as possible? So I would suggest maybe using 2147483647 as divisor (or even PHP_INT_MAX, I'm not sure).

Also, since there's no reason to believe that this VA is set before it is gotten (or that something else manipulates these php config vars) I think it would be safer for the getter to return something along the lines of:

ini_get('session.gc_probability')/ini_get('session.gc_divisor');

Let me know what you think.

@resurtm
Copy link
Contributor

resurtm commented Aug 25, 2012

First, bumping the divisor up to 100000 seems a little arbitrary to me. If Yii offers the user a float for $gCProbability, why not allow as much range as possible? So I would suggest maybe using 2147483647 as divisor (or even PHP_INT_MAX, I'm not sure).

I think the value 2147483647 would be enough for any case and any situation user can have. And fixed value (2.1*10^9) would be better than PHP_INT_MAX because the latter is different across various platforms and architectures.

Also, since there's no reason to believe that this VA is set before it is gotten (or that something else manipulates these php config vars) I think it would be safer for the getter to return something along the lines of:

That makes sense. Thanks! Will fix it soon.

@resurtm
Copy link
Contributor

resurtm commented Aug 25, 2012

@tom-- I'm done.

@ghost ghost assigned cebe Aug 29, 2012
cebe added a commit that referenced this issue Aug 29, 2012
…ttps://github.com/resurtm/yii into resurtm-486-http-session-gc-probability

* '486-http-session-gc-probability' of https://github.com/resurtm/yii:
  Refinements and $gCProbability now can be 0.00000005% not just a 0.001%.
  Enh #486: CHttpSession::$gCProbability and CDbHttpSession::$gCProbability are floats now. Minimal $gCProbability value has been changed to the 0.001%, was 1% before, default value left unchanged (1%).

Conflicts:
	CHANGELOG
@cebe cebe closed this as completed Aug 29, 2012
@resurtm
Copy link
Contributor

resurtm commented Aug 29, 2012

@tom-- So, fix was merged into upstream. Did you tried it?

@tom--
Copy link
Contributor Author

tom-- commented Aug 29, 2012

@resurtm not yet. the testing is going to require some sophistication and to estimate the probability will need statistical sampling and many runs. plus i should figure out first how to write a unit test that i can create a PR for. this week, i hope.

@tom--
Copy link
Contributor Author

tom-- commented Aug 29, 2012

as for the PR for the unit test, it's probably no different than any other, yes?
https://github.com/yiisoft/yii/wiki/Git-workflow-for-Yii-contributors

@resurtm
Copy link
Contributor

resurtm commented Aug 29, 2012

@tom-- Okay. I'm also testing this issue.

@resurtm
Copy link
Contributor

resurtm commented Aug 29, 2012

@tom-- Yes, the process completely same.

@tom--
Copy link
Contributor Author

tom-- commented Aug 29, 2012

should i include in one PR the new CTestCase script file and fixes to CHttpSession.php so that it passes the new tests?

@resurtm
Copy link
Contributor

resurtm commented Aug 29, 2012

@tom-- yes, sure. That's ok.

@tom-- tom-- mentioned this issue Aug 29, 2012
@tom--
Copy link
Contributor Author

tom-- commented Aug 29, 2012

i added github code comments to the PRs diff view: #1309

cebe added a commit that referenced this issue Aug 31, 2012
cebe added a commit to cebe/yii that referenced this issue Sep 3, 2012
…tion

* master: (180 commits)
  Updated changelog with last-modified date change.
  Changed the CHttpCacheFilter to use RFC 1123 complaint dates when returning the last-modified header.
  tabs...
  gii: better default validation "length" rule for fixed-point / floating-point field type (MYSQL)
  fixes yiisoft#1319
  updated comment in CHttpSession
  Update framework/YiiBase.php
  Update docs/guide/database.arr.txt
  New unit test for enhanced $gCProbability s/getters in CHttpSession yiisoft#486. Fixed those methods to process corner cases properly. Initial $gCProbability is now double(1.0), was > 1.0 before.
  Bug yiisoft#112: MSSQL: database abstraction layer now uses native transaction support of the SQLSRV driver.
  Forgot about spaces in comments creating procedure call. [ci skip]
  Better comments testing method name.
  Forgot about local MSSQL database settings.
  MSSQL unit testing SQL file reformatted and decorated. MSSQL testing class improved. Added unit tests for column comments retrieving.
  Removed old message.
  Update docs/guide/topics.i18n.txt
  Update docs/guide/topics.i18n.txt
  Requirements checker: russian (ru_RU) messages.
  Minor fixes and refinements to the MSSQL unit tests.
  better fix for issues yiisoft#124
  ...

Conflicts:
	UPGRADE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants