api-benchmarks icon indicating copy to clipboard operation
api-benchmarks copied to clipboard

Pakyow

Open mzniko opened this issue 11 years ago • 9 comments

David,

Thought I would contribute by adding the little-known Pakyow framework (they advertise 45% faster than Sinatra!). They released 0.8 a couple weeks ago, adding significant changes to their router.

http://pakyow.com/ http://pakyow.com/docs

Unfortunately, I'm having some trouble on my local machine getting 'rake benchmark:pakyow' to actually start the server properly (I get an 'unable to connect to 0.0.0.0:9292 Connection refused' error), and if I 'bundle exec rackup pakyow', I'm unable to access my wiggles! My postgres install seems to be fine and the db was properly populated with db:setup, so, I'm not sure what is going on.

Past the aforementioned db issue, the rest of it should work as expected. Pakyow has a strange view-first architecture, so it actually requires the existence of a view/_templates folder and a pakyow.html file. The names of those folders and the default file can be changed, but I don't know how to eliminate their necessity. The rest of the changes should be self-explanatory. Sorry I couldn't fully test!

Marko

PS. this is my first real life pull request ever!

mzniko avatar Apr 03 '14 07:04 mzniko

Well this is weird:

~Code/api-benchmarks mzniko-pakyow! % bundle exec rackup pakyow.ru                                                           2.1.1
/Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require': cannot load such file -- rspec (LoadError)
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/bundler/gems/crepe-ce38920ef627/spec/spec_helper.rb:3:in `<top (required)>'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/loader.rb:26:in `block in require_recursively'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:14:in `block in walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:14:in `each'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:14:in `walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `block in walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `each'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `block in walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `each'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `block in walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `each'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `block in walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `each'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `block in walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `each'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `block in walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `each'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/utils/dir.rb:15:in `walk_dir'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/loader.rb:16:in `require_recursively'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/loader.rb:8:in `load_from_path'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/app.rb:401:in `load_app'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/app.rb:196:in `initialize'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/app.rb:157:in `new'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/app.rb:157:in `prepare'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/app.rb:87:in `stage'
    from /Users/david/Documents/Code/api-benchmarks/pakyow.ru:34:in `block in <main>'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
    from /Users/david/Documents/Code/api-benchmarks/pakyow.ru:in `new'
    from /Users/david/Documents/Code/api-benchmarks/pakyow.ru:in `<main>'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/bin/rackup:23:in `load'
    from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/bin/rackup:23:in `<main>'

davidcelis avatar Apr 03 '14 15:04 davidcelis

Ah, I think this line is the culprit:

from /Users/david/Documents/Code/api-benchmarks/vendor/bundle/gems/pakyow-core-0.8.0/pakyow-core/lib/core/loader.rb:26:in `block in require_recursively'

My guess is Pakyow's loader is attempting to load other files related to other frameworks and causing issues with bundler...

davidcelis avatar Apr 03 '14 15:04 davidcelis

Thanks for the PR by the way! I'll try to see if I can help make it work. I discovered Pakyow fairly recently and found the routing/templating systems to be pretty weird :sweat_smile:

davidcelis avatar Apr 03 '14 15:04 davidcelis

Aha:

module Pakyow
  class App
    def load_app
      call_stack(:before, :load)

      # load src files
      @loader = Loader.new
      @loader.load_from_path(config.app.src_dir)

      # load the routes
      load_routes

      call_stack(:after, :load)
    end
  end
end

So with the src_dir set to ./, it's attempting to require every file, including those in vendor/bundle. So it's traversing that directory, gets to random gems it shouldn't be trying to access, and requires files from them. Including a framework's spec_helper!

It looks like src_dir has a default:

def src_dir
  @src_dir || "#{root}/app/lib"
end

I have no idea why app/lib/ would exist in a project but it doesn't appear that the directory's existence matters, so not having app/lib/ doesn't raise an exception. We should just leave it at its default.

davidcelis avatar Apr 03 '14 15:04 davidcelis

Ahhh. That makes sense! I should have looked at the source. I realize now I didn't even need to change the src config to './'. That little bit was a remnant of me trying to make sense of the framework at the early stages.

I didn't get that error because I don't have a vendor folder in my cloned repo. I'm using rvm and gemsets in ubuntu 13.10.

mzniko avatar Apr 03 '14 16:04 mzniko

What's the status on this merge?

krainboltgreene avatar Jun 22 '14 04:06 krainboltgreene

Sorry :( very little time on my hands lately. This is dormant for now. Please look into it if you have time!

mzniko avatar Jun 22 '14 04:06 mzniko

Does the problem suggest that we need to isolate each benchmark in a more direct manner?

krainboltgreene avatar Jun 22 '14 05:06 krainboltgreene

No, it's just a Pakyow configuration thing. I can take care of this PR myself if @mzniko doesn't have time to finish it up!

davidcelis avatar Jun 22 '14 06:06 davidcelis