-
Notifications
You must be signed in to change notification settings - Fork 5
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
Rucksack is sometimes very slow #8
Comments
Sometimes I also see:
Maybe this is related? |
May workaround for the moment: require "http/server/handler"
require "mime"
# enable rucksack only on release builds
{% if flag?(:release) %}
require "rucksack"
{% for name in `find ./src/static -type f`.split('\n') %}
rucksack({{name}})
{% end %}
{% end %}
class StaticHandler
include HTTP::Handler
def call(context)
if context.request.path.starts_with?("/static")
path = "./src#{context.request.path}"
if type = MIME.from_filename?(path)
context.response.content_type = type
end
{% if flag?(:release) %}
begin
rucksack(path).read(context.response.output)
return
rescue Rucksack::FileNotFound
end
{% else %}
begin
File.open(path) do |file|
IO.copy(file, context.response.output)
return
end
rescue File::NotFoundError
end
{% end %}
end
call_next(context)
end
end |
Hmm. Is it consistently slow or "sometimes slow, sometimes fast"? And is the final binary (with rucksack attached) also slow, The error seems to suggest broken read-after-write semantics. At compile-time According to your error message the file apparently did Are you perhaps compiling on a network filesystem (samba / NFS)? I don't have Windows / WSL to test, so I'm afraid can only defer to the note |
Is is not deterministic, so yes, sometimes slow and sometimes "fast". However it is not really fast. The final binary is fast. Only the compile time is slow. Interesting, regarding the read-after-write. Im using crystaline could this maybe interfer with the creation of the file? So maybe it is a concurrent use issue? As I'm coding while waiting for the build I "feel" it is related to my work. Does rucksack "wait" somehow and could another compile break it? I'm not working on samba/NFS but on the wsl disk:
So it should not be the issue. I also moved the whole project to |
Crystalline might indeed be related (I don't know how it works under the hood, 2 seconds sounds about right, the This part of rucksack is def worth optimising at some point but I haven't gotten around to it, yet. (I think back in the day I was reluctant to pollute the filesystem with a temp-binary |
Problem
I want to use rucksack to embed static files with the binary. I use no other external binary but rucksack.
The directory only includes one file:
The application is fast on start up using
crystal run ...
without rucksack (1 sec).Way I measured:
Manually doing the find:
Environment
The text was updated successfully, but these errors were encountered: