We are writing to the cache ($m->cache) too often--on
every requests. This is a race condition, and even
though this race condition should not harm the program,
it hurts performance.
Condition:
<TABLE BORDER=1>
<TR><TH>Request A</TH><TH>Request B</TH></TR>
<TR><TD>Create Session 1</TD><TD></TD></TR>
<TR><TD></TD><TD>Create Session 2</TD></TR>
<TR><TD>Finish, store entire hash in Mason
cache</TD><TD></TD></TR>
<TR><TD></TD><TD>Finish, store entire hash in Mason
cache</TD></TR>
</TABLE>
In this case, the hash in the cache will only contain
session 2. This does not harm the program, as session
1 will be retrieved from the database if it needs to be
accessed again, but it was unnecessary to write session
1 to disk since it would be overwritten.
I propose we lock the cache for writes.
Logged In: YES
user_id=312414
Well, shit, I guess HTML doesn't work in here. :(
For ASCII users:
Request A: Read Mason cache (empty)
Request A: Create Session 1
Request B: Read Mason cache (still empty)
Request B: Create Session 2
Request A: Finish, store entire hash in Mason cache (just
session 1)
Request B: Finish, store entire hash in Mason cache (just
session 2)