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

Rework global variables, caching to eliminate race conditions #4808

Open
headius opened this Issue Oct 9, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@headius
Member

headius commented Oct 9, 2017

This issue spawned from discoveries in #4797, where @eregon discovered that various races in our global variable subsystem seem to be causing us to cache invalid values.

There are numerous races, including but not limited to:

  • GlobalVariables uses a CHM but manually performs multi-step read/write operations that would race with other threads.
  • UndefinedVariable modifies the GlobalVariable it was attached to, updating it with a different accessor. This makes caching the accessor impossible.
  • The traces active for each global variable are managed in an unsynchronized ArrayList, which additionally can be modified from outside the subsystem.

There are likely others. The main problems lie in the fact that this part of JRuby is some of the oldest code, many files only bearing the copyright of the first committer to JRuby. None of this code was built for concurrency, and the many levels of abstraction and mutation make a simple fix impossible.

This bug will track a rework of the global variable subsystem for JRuby 9.2, which will eliminate some of the unnecessary abstraction, use appropriate thread-safe structures and synchronization for modification, and properly enable safe caching of values.

@headius headius added this to the JRuby 9.2.0.0 milestone Oct 9, 2017

@sumitmah

This comment has been minimized.

Show comment
Hide comment
@sumitmah

sumitmah Oct 10, 2017

I remember discussing similar stuff mruby with Matz in Rubyconf.

sumitmah commented Oct 10, 2017

I remember discussing similar stuff mruby with Matz in Rubyconf.

@headius

This comment has been minimized.

Show comment
Hide comment
@headius

headius May 17, 2018

Member

We did various amounts of work to improve globals during the 9.1 cycle, but I have not evaluated how well the current implementation deals with globals. The plumbing is still a bit messy and I'm sure there are remaining races, plus we have never really reenabled global optimization in indy the way I'd like.

Bumping to post 9.2 for additional work.

Member

headius commented May 17, 2018

We did various amounts of work to improve globals during the 9.1 cycle, but I have not evaluated how well the current implementation deals with globals. The plumbing is still a bit messy and I'm sure there are remaining races, plus we have never really reenabled global optimization in indy the way I'd like.

Bumping to post 9.2 for additional work.

@headius headius modified the milestones: JRuby 9.2.0.0, JRuby 9.2.1.0 May 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment