-
Notifications
You must be signed in to change notification settings - Fork 115
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
Issue #381 Reduce the number of Eval calls #396
Merged
EthanEChristian
merged 15 commits into
oracle-samples:master
from
EthanEChristian:ISSUE-381-Perf
Aug 13, 2018
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9a14587
Issue-381: Reduce number of calls to eval by the compiler
EthanEChristian 9f995cc
ISSUE-381: Add Perfomance tests
EthanEChristian 3cf249e
Add doc for :compilation-partition-size
EthanEChristian 6aa5781
Performance test modifications
EthanEChristian df30ddf
Address naming conventions
EthanEChristian bc6cb19
Update Changelog.
EthanEChristian ef22488
Update the number of forms per eval
EthanEChristian b0f07f3
Add alpha-nodes to id-to-node, Update exception message, Refactor fre…
EthanEChristian 4f2d8c2
Add test for exceeding form batch size. Add doc
EthanEChristian 4988d57
Merge branch 'master' into ISSUE-381-Perf
EthanEChristian 4ae6611
Minor spelling mistake
EthanEChristian a5a5064
Rename variables, Extract functions
EthanEChristian 5d6e8c2
Change structure of expr-lookup, move test to long-running ns
EthanEChristian ce9a2db
Merge remote-tracking branch 'upstream/master' into ISSUE-381-Perf
EthanEChristian d24f8a3
Update comments, Use identical over =, Add exception to compilation
EthanEChristian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1391,7 +1391,12 @@ | |
:join-filter-expressions (:join-filter-expressions beta-node) | ||
:env (:env beta-node) | ||
:msg "compiling accumulate with join filter node"}})) | ||
:query prev))) | ||
:query prev | ||
|
||
;; This error should only be thrown if there are changes to the compilation of the beta-graph | ||
;; such as an addition of a node type. | ||
(throw (ex-info "Invalid node type encountered while compiling rulebase." | ||
{:node beta-node}))))) | ||
id->expr | ||
(:id-to-condition-node beta-graph)))) | ||
|
||
|
@@ -1448,9 +1453,10 @@ | |
"A helper function for retrieving a given key from the provided map. If the key doesn't exist within the map this | ||
function will throw an exception." | ||
[m k] | ||
(let [v (get m k ::not-found)] | ||
(if (= v ::not-found) | ||
(throw (ex-info "Key not found with safe-get" {:map map :key k})) | ||
(let [not-found ::not-found | ||
v (get m k not-found)] | ||
(if (identical? v not-found) | ||
(throw (ex-info "Key not found with safe-get" {:map m :key k})) | ||
v))) | ||
|
||
(sc/defn ^:private compile-node | ||
|
@@ -1875,34 +1881,34 @@ | |
(throw (ex-info (str "Non-unique production names: " non-unique) {:names non-unique}))))) | ||
|
||
(def forms-per-eval-default | ||
;; The default max number of forms that will be evaluated together as a single batch. | ||
;; 5000 is chosen here due to the way that clojure will evaluate the vector of forms extracted from the nodes. | ||
;; The limiting factor here is the max java method size (64KiB), clojure will compile each form in the vector down into | ||
;; its own class file and generate another class file that will reference each of the other functions and wrap them in | ||
;; a vector inside a static method. For example, | ||
;; | ||
;; (eval [(fn one [_] ...) (fn two [_] ...)]) | ||
;; would generate 3 classes. | ||
;; | ||
;; some_namespace$eval1234 | ||
;; some_namespace$eval1234$one_1234 | ||
;; some_namespace$eval1234$two_1235 | ||
;; | ||
;; some_namespace$eval1234$one_1234 and some_namespace$eval1234$two_1235 contian the implementation of the functions, | ||
;; where some_namespace$eval1234 will contain two methods, invoke and invokeStatic. | ||
;; The invokeStatic method breaks down into something similar to a single create array call followed by 2 array set calls | ||
;; with new invocations on the 2 classes the method then returns a new vector created from the array. | ||
;; | ||
;; 5000 is lower than the absolute max to allow for modifications to how clojure compiles without needing to modify this. | ||
;; The current limit should be 5471, this is derived from the following opcode investigation: | ||
;; | ||
;; Array creation: 5B | ||
;; Creating and populating the first 6 elements of the array: 60B | ||
;; Creating and populating the next 122 elements of the array: 1,342B | ||
;; Creating and populating the next 5343 elements of the array: 64,116B | ||
;; Creating the vector and the return statement: 4B | ||
;; | ||
;; This sums to 65,527B just shy of the 65,536B method size limit. | ||
"The default max number of forms that will be evaluated together as a single batch. | ||
5000 is chosen here due to the way that clojure will evaluate the vector of forms extracted from the nodes. | ||
The limiting factor here is the max java method size (64KiB), clojure will compile each form in the vector down into | ||
its own class file and generate another class file that will reference each of the other functions and wrap them in | ||
a vector inside a static method. For example, | ||
|
||
(eval [(fn one [_] ...) (fn two [_] ...)]) | ||
would generate 3 classes. | ||
|
||
some_namespace$eval1234 | ||
some_namespace$eval1234$one_1234 | ||
some_namespace$eval1234$two_1235 | ||
|
||
some_namespace$eval1234$one_1234 and some_namespace$eval1234$two_1235 contian the implementation of the functions, | ||
where some_namespace$eval1234 will contain two methods, invoke and invokeStatic. | ||
The invokeStatic method breaks down into something similar to a single create array call followed by 2 array set calls | ||
with new invocations on the 2 classes the method then returns a new vector created from the array. | ||
|
||
5000 is lower than the absolute max to allow for modifications to how clojure compiles without needing to modify this. | ||
The current limit should be 5471, this is derived from the following opcode investigation: | ||
|
||
Array creation: 5B | ||
Creating and populating the first 6 elements of the array: 60B | ||
Creating and populating the next 122 elements of the array: 1,342B | ||
Creating and populating the next 5343 elements of the array: 64,116B | ||
Creating the vector and the return statement: 4B | ||
|
||
This sums to 65,527B just shy of the 65,536B method size limit." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a blocker, but this increases the importance of setting up our tests against all relevant Clojure versions in Travis since potentially different/future Clojure versions could have differences here. That is really something we should be doing anyway though. |
||
5000) | ||
|
||
(sc/defn mk-session* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
+1 to this approach to enforcing identity equality