-
Notifications
You must be signed in to change notification settings - Fork 276
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
Very slow rake, rspec, and server startup #269
Comments
I altered the code to get a better idea if this is getting executed over and over again: def country=(country_string)
puts "[#{Time.now.strftime('%H:%M:%S.%L')}] country=#{country_string}"
value = Carmen::Country.named(country_string) || Carmen::Country.coded(country_string.try(:upcase))
puts "[#{Time.now.strftime('%H:%M:%S.%L')}] country=#{country_string} done"
self.country_code = value.code if value.present?
end Here's a better set of traces, looks like 28s on first invokation of all stacks
Notable findings:
So the first hit is very time consuming. Any thoughts/ideas? Am I doing something wrong? |
So putting the value = Carmen::Country.coded(country_string.try(:upcase)) || Carmen::Country.named(country_string) Interesting to note that the |
what does .named do? string search of all country names regardless of
language? I guess that's useful, and possibly slow. Probably countries
should be a dictionary on iso e code. And search by strings should go
through an index, maybe just a skip list:
{
"sv": { "is": ["CHE"], "er": ["SWE"] },
}
Then take input.downcase.clean_whitespace of Svissera or Sverige and match.
The last step is to check an array of possible hits for the right match.
When building the index we'd skip some words, since we don't need an exact
match: the la le el democratic republic of de en ...
If this is the wrong place or API, sorry. I might have mixed up gems re.
which has/lacks lookup by name. I need an address parsing step before
deciding which geocoder to use, which could be a use case for carmen.
Thanks for the word
…On Tue, Oct 9, 2018, 21:39 Kevin Ross ***@***.***> wrote:
So putting the coded search first is far faster - should have done that
first instead of named. I think this solves my issue.
value = Carmen::Country.coded(country_string.try(:upcase)) ||
Carmen::Country.named(country_string)
Interesting to note that the named method takes so long - I'm not going
to allow it in our codebase anymore.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#269 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAi2YBhaH_VjJAQ5M8NLORBQye7xvmrks5ujPtzgaJpZM4XT7ux>
.
|
/related? #141 - closed
Carmen is in use by our seeds and rspec, which is where I started to try and diagnose our very slow behavior. This ended up pointing at carmen. I used the stack dump process described here. Here is the code I used:
I see up to ~30s of (seeming) inactivity. During this time, I made several stack dumps e.g.
kill -USR1 97048
Some of the code shown being executed in seeds is
address.rb
which uses carmen:Gory details
Here are the stack traces, ~1 per few seconds
TL;DR
Our spec code on startup is involved with carmen for 20s (and up to 30s) in what seems to be routine seeding
[13:54:00.741]
[13:54:20.462]
Am I missing something? Is this the expected performance? Am I missing out on some carmen caching?
The text was updated successfully, but these errors were encountered: