Permalink
Browse files

First of the incremental optimizations (this one gets about 25%):

- remove some unnecessary proc { ... }.call stuff, and cleanup the translated
  ruby source.
- add _x variants of some of the runtime modifier functions, that use blocks
  instead of procs. then deleted the originals. will rename back later.
  • Loading branch information...
Charles Lowe
Charles Lowe committed Sep 17, 2008
1 parent 758634c commit 0b1123a4956f8e88b1c5c52d60046c046fed42a9
Showing with 127 additions and 108 deletions.
  1. +3 −0 README
  2. +21 −3 Rakefile
  3. +68 −68 lib/ometa/bootstrap.rb
  4. +23 −25 lib/ometa/runtime.rb
  5. +12 −12 ometa/ometa_translator.ometa
View
3 README
@@ -8,3 +8,6 @@ Briefly what OMeta is, some links to the ometajs stuff.
similar, and use them based on mtime / flag combination.
* try to optimize some more. profile wasn't particularly illuminating.
* then write some actual tests.
+* i think that super is actually broken at the moment, and its not used
+ in the standard grammar. the js one uses it, so could test with that.
+
View
@@ -20,12 +20,12 @@ module Bootstrap
class V0 < Object
end
- def single root=V0
- puts "bootstrapping ometa using #{root.inspect}"
+ def single root=V0, quiet=false
+ puts "bootstrapping ometa using #{root.inspect}" unless quiet
all = ''
BOOTSTRAP_GRAMMARS.each do |filename|
- puts " - #{filename}"
+ puts " - #{filename}" unless quiet
grammar = File.read(File.dirname(__FILE__) + '/ometa/' + filename)
ast = root.const_get('OMetaParser').matchAllwith(grammar, 'grammar')
ast = root.const_get('OMetaOptimizer').matchwith(ast, 'optimizeGrammar')
@@ -83,3 +83,21 @@ task :bootstrap do
end
end
+desc 'Simple benchmark'
+task :bench do
+ # all we do is run the complete bootstrap 3 times.
+ # this currently takes about 44-48 seconds currently on my laptop (~1.4Ghz single core).
+ # they're pretty simple grammars, so ideally this'd take more like a few seconds...
+ # ok after using _x* variant functions which use blocks instead of procs, and removing
+ # some other unnecessary procs, we get this down to 30 s. this also has the nice side
+ # effect of reducing the size of bootstrap.rb from 13kb down to 10kb.
+ # can get it down to 28 with a bit more of that. will now try inlining _or() alternations
+ # to avoid the only remaining need for procs. if that doesn't have an appreciable impact,
+ # (eg > 5s), i'll revert it and focus on runtime.rb, which is probably where the slowness
+ # is - implementation of streams, memoization, the _apply function etc.
+ # just tested it on ruby1.9, and the speed was the same.
+ t = Time.now
+ 3.times { Bootstrap.single Bootstrap::V0, true }
+ puts "3 bootstraps took #{Time.now - t} seconds"
+end
+
Oops, something went wrong.

0 comments on commit 0b1123a

Please sign in to comment.