-
Notifications
You must be signed in to change notification settings - Fork 92
[#36] allow changing almost everything in Config using System Properties #67
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
Conversation
…operties * note: used underscores instead of periods used in the joni.debug* options
|
I love it! Will review and chat with other maintainers. |
headius
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great overall! Just a few minor changes needed.
| int tail = targetEnd - 1; | ||
| int tlen1 = tail - targetP; | ||
| if (USE_SUNDAY_QUICK_SEARCH) { | ||
| tlen1 = tail - targetP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this fixing a separate bug? If so we should move it to another PR because it's not config-related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I changed USE_SUNDAY_QUICK_SEARCH to be initialized from system property it no longer compiled
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project joni: Compilation failure: Compilation failure:
[ERROR] /Users/nezda/code/joni.git/src/org/joni/Search.java:[438,59] variable tlen1 might not have been initialized
[ERROR] /Users/nezda/code/joni.git/src/org/joni/Search.java:[446,59] variable tlen1 might not have been initialized
so I tried to fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pinged @enebo to look at this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it was constant propagated since those interface fields are essentially static finals
|
It will disable constant propagations for those flags, I dont have an opinion on it though |
Seems like conservative thing to do is preserve whatever performance constant propagation gets us and just don't let |
|
Oh, I was referring to all flags, those affecting parser shouldnt matter though. |
|
It is interesting an implicitly final variable initialized in that way stops being treated as a constant (but it seems clear something is going on related to that since code failed to compile without modification). I suppose final local variables could be introduce to ferry in values from those "constants" in that interface? |
|
static finals where a direct translation for c #ifdef macros - I dont recall anything that could be a substitute for that in java. |
|
I always thought final variables were basically equivalent to c #ifdef. I think this is my first counter-example. I could introduce a Configuration object with all final fields initialized in a constructor which would have benefit different instances within same jvm could have different configurations. |
|
There's at least two types of finals in java, static finals complete disapear from bytecode. So, dead branches will also make the bytecode smaller. |
|
Yeah, @lopex is right that this will prevent javac from eliminating code paths that were impossible to reach with literal static final values. That's why that sunday search code you patched suddenly started failing; with the original I think the utility of making these configurable is worth any possible bytecode size increase here, even though it may tweak the inlining decisions of various JVMs. It should not generally affect performance when the same things inline as before, but some methods may cross size thresholds that prevent them from being trivially inlinable after this change. If we could come up with a good way to audit which methods are affected by this, we could always move the conditional bodies out to separate static methods so they are small and don't impact the size of the original. There would be an additional inline that has to happen, so we'd have to weigh that against shrinking methods. We can make some determination by benchmarking expression matches that hit such methods heavily. Personally, I would be surprised if this ends up being observable, and since there's no way to make these configurable without breaking the javac dead code optimization it may just be a price we have to accept (if it really has a cost). |
|
I would probably say we should just merge and then look at doing some benchmarking to find any performance regressions. We want these things to be configurable to make joni more flexible (to users other than JRuby also), so there may just be additional work necessary to find any slowdowns and deal with them. |
|
For what it's worth, I concur with vote to merge this. I'd also be surprised if this had any significant negative performance consequence. |
|
One followup to places where we do decide something is performance sensitive. We can split some of these things into separate types so we end up with more copies of some part of the code at the benefit of not having these ifdef sections. I also think this should merge and if possible we can see if we really see any perf differences. |
|
Merged! We are debating some other fixes for release but otherwise we'll push this out soon. |
|
Moved to 2.2.0 because we're also landing some API changes (and this deprecates and changes some API as well). |
[#36] allow changing almost everything in Config using System Properties
Search.javafor the change to compile