Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Coercer's cache may contains keys that are binded to memory location. #2515

Open
ericproulx opened this issue Dec 19, 2024 · 0 comments
Open

Comments

@ericproulx
Copy link
Contributor

ericproulx commented Dec 19, 2024

While looking at the Coercer's cache, I've found that some keys have a weird name. When running the specs, I've found the followings :

__[[String]]_#<Proc:0x0000ffff81c8aad8 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:652 (lambda)>_false
__Array_#<Proc:0x0000ffff81d746b0 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:693 (lambda)>_false
__Array_#<Proc:0x0000ffff81e168c0 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:618 (lambda)>_false
__[String]_#<Proc:0x0000ffff81e53158 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:635 (lambda)>_false
__Hash_#<Method: JSON.parse(source, opts=...) /usr/local/bundle/gems/ruby/3.3.0/gems/json-2.9.1/lib/json/common.rb:220>_false
__Integer_#<Proc:0x0000ffff81ef4788 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:774 (lambda)>_false
__[Integer]_#<Proc:0x0000ffff8209a7b8 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:676 (lambda)>_false
__Integer_#<Proc:0x0000ffff821b1b10 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:835 (lambda)>_false
__Integer_#<Proc:0x0000ffff83295008 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:835 (lambda)>_false
__Integer_#<Proc:0x0000ffff87ade300 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:835 (lambda)>_false
__Integer_#<Proc:0x0000ffff83324168 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:797 (lambda)>_false
__Integer_#<Proc:0x0000ffff8301aff8 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:797 (lambda)>_false
__Integer_#<Proc:0x0000ffff83159e50 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:797 (lambda)>_false
__Array_#<Proc:0x0000ffff8216a468 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:711 (lambda)>_false
__Array_#<Proc:0x0000ffff82030d68 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:711 (lambda)>_false
__Array_#<Proc:0x0000ffff82095808 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:711 (lambda)>_false
__[Grape::API::Boolean, String]_#<Proc:0x0000ffff81c4aa78 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:82 (lambda)>_false
__[Grape::API::Boolean, String]_#<Proc:0x0000ffff81c91d60 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:82 (lambda)>_false
__[Grape::API::Boolean, String]_#<Proc:0x0000ffff81ce0c58 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:82 (lambda)>_false
__[Grape::API::Boolean, String]_#<Proc:0x0000ffff81e53108 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:1129 (lambda)>_false
__[Grape::API::Boolean, String]_#<Proc:0x0000ffff81ea4800 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:1129 (lambda)>_false
__[Grape::API::Boolean, String]_#<Proc:0x0000ffff81f155c8 /var/grape/spec/grape/validations/validators/coerce_validator_spec.rb:1129 (lambda)>_false
__String_#<Proc:0x0000ffff81f221d8(&:strip) (lambda)>_false

It seems to leak like that since we have different memory address for the same location but its just because its different tests. I've tested it on a web server with a single process with 5 threads and the memory address stays the same.

I think we can do better and probably warm the cache during the compilation time instead of the runtime. That would save some synchronization with the threads when warming it.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant