Skip to content
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

Optimisation: do not re-access mapper properties inside the request loop #1223

Merged
merged 1 commit into from Jun 13, 2022

Conversation

ml-evs
Copy link
Member

@ml-evs ml-evs commented Jun 3, 2022

Closes #1219 by accessing the config variables outside of the response field loop.

@codecov
Copy link

codecov bot commented Jun 3, 2022

Codecov Report

Merging #1223 (145a0aa) into master (991591b) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 145a0aa differs from pull request most recent head e591e18. Consider uploading reports for the commit e591e18 to get more accurate results

@@            Coverage Diff             @@
##           master    #1223      +/-   ##
==========================================
- Coverage   91.28%   91.27%   -0.02%     
==========================================
  Files          72       72              
  Lines        4292     4287       -5     
==========================================
- Hits         3918     3913       -5     
  Misses        374      374              
Flag Coverage Δ
project 91.27% <100.00%> (-0.02%) ⬇️
validator 90.66% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...made/server/entry_collections/entry_collections.py 97.72% <100.00%> (+0.03%) ⬆️
optimade/server/routers/info.py 95.45% <0.00%> (-0.20%) ⬇️
optimade/server/config.py 91.39% <0.00%> (-0.19%) ⬇️
optimade/server/entry_collections/elasticsearch.py 97.40% <0.00%> (-0.13%) ⬇️
optimade/server/routers/utils.py 98.13% <0.00%> (ø)
optimade/server/exception_handlers.py 84.28% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 991591b...e591e18. Read the comment docs.

@ml-evs ml-evs added priority/high Issue or PR with a consensus of high priority server Issues pertaining to the example server implementation labels Jun 9, 2022
Copy link
Contributor

@JPBergsma JPBergsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I wonder how many other cases there are in our code where we call a function within a loop where calling it once outside the loop would suffice.
On second thought, should we not change the case of the ALL_ATTRIBUTES, SUPPORTED_PREFIXES and perhaps some of the other methods of the BaseResourceMapper to small case ? They are not really constants, so I do not think they should be in capitals.

@ml-evs
Copy link
Member Author

ml-evs commented Jun 13, 2022

LGTM, I wonder how many other cases there are in our code where we call a function within a loop where calling it once outside the loop would suffice.

This is the only place I could spot these being used, we could do some better caching but it would probably require breaking changes.

On second thought, should we not change the case of the ALL_ATTRIBUTES, SUPPORTED_PREFIXES and perhaps some of the other methods of the BaseResourceMapper to small case ? They are not really constants, so I do not think they should be in capitals.

I'm not sure its worth breaking backwards-compatibility for, but I agree that there is not really a good reason why they are capitalised... I guess they should be constant for a particular running server, at least (which was probably our rationale).

@ml-evs ml-evs force-pushed the ml-evs/cache_config_properties branch from 145a0aa to e591e18 Compare June 13, 2022 19:31
@ml-evs ml-evs changed the title Do not re-access config properties inside the request loop Optimisation: do not re-access mapper properties inside the request loop Jun 13, 2022
@ml-evs ml-evs enabled auto-merge (squash) June 13, 2022 19:32
@ml-evs ml-evs merged commit 55a2731 into master Jun 13, 2022
@ml-evs ml-evs deleted the ml-evs/cache_config_properties branch June 13, 2022 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/high Issue or PR with a consensus of high priority server Issues pertaining to the example server implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config values are not cached by @classproperty
2 participants