This is middle ground between caching it completely and requiring a
restart/signal to reload vs always reloading it.
I don't know any use cases that can break from this, nowhere in code
configs should be expected to reload instantly.
This change is only applied to requests for now
This makes maxsize deterministic while estimating memory costs of
using this function.
E.g. If I want to cache site config and I'd prefer to keep 16 recent
site configs in memory, there's no way to handle this. Site specific
maxsize means if I have 1000 sites on bench I'll have 1000 keys in
cache.
This change makes behaviour similar to lru_cache which is how I thought
it workerd TBH.
RESP3 has PUSH support which is useful for implementing client side
caching. Enabling this before I work on that to test if anything breaks
with this.
No need to do this for background jobs instance just yet, infrequent
accesses and performance doesn't matter as much.
* upstream/develop: (1373 commits)
perf: cache dynamic links map in Redis (#28878)
fix: Never query `flag_print_sql` in `developer_mode=0` (#28884)
fix(restore): remove MariaDB view security definers
fix: sanitize user input during setup wizard
feat(sanitize_column): improve check
refactor: make optimizations.py private entirely (#28872)
fix(site_cache): site cache thread safety (#28870)
chore(printview): change error message
perf: speedup `frappe.call` by ~8x (#28866)
test: reduce noise in test output (#28862)
chore: spelling_invalid_values (#28858)
fix: Remove misleading os.O_NONBLOCK flag (#28859)
fix: string replacement in error logger
perf(gthread): Pin web workers to a single core (#28854)
fix: MariaDBDatabase.get_tables() should not query the entire database schema (#28846)
fix: add strings and fields to translation
fix: typo in test controller boilerplate
perf: faster add_to_date (#28843)
perf(version): Make get_versions fast for autoincrement doctypes (#28847)
refactor: log in monitor as well
...
Identified two cases where site cache can break:
1. Other thread clears cache using clear_cache because of TTL or manual
eviction.
2. Other thread pops the eliment we are about to read because of
`maxsize` limit.
This change should fix both and even make it lil bit faster.
* perf: resolve rounding method once
When rounding method is explcitly specified it's 1.4x faster.
* perf: reorder checks
Bankers rounding is default and most common now
* perf: speedup get_system_settings
* fix: fallback for always printing tracebacks
I don't recall ever hitting "no" to this prompt. It's of no use for me.
Also, this makes automated scripts not really automated.
* revert: prompting for exceptions
Always print full exception
* perf: Use latest pickle protocol
* perf: pop flags from cached documents
This is also the right thing to do, things like `doc.flags.for_update`
shouldn't be "cached".
- Eagerly initialize request_cache, all requests use it, so what is the
point of doing it lazily?
- Reduce accesses to `frappe.local` namespace, get cache once and reuse
it in rest of the execution.
Before: 1250ns +/- 1%
After: 645ns +/- 1%
Source: Trust me bro.
(no really, for now just trust me or look at the diff)
Just like LRU cache, no need to support unhashable types in site_cache.
Current usage in codebase also shows that it's not required and json.dumps is quite slow.
If a job has been retried, we'll enter the finally section after `frappe.destroy()` has been called
Additionally, only run these on the "original" call, not on each retry call
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
* feat: Add bench layout classes and configuration handler
Bench layout: (`frappe.bench`)
- Layout by env variable, e.g. FRAPPE_BENCH_PATH, FRAPPE_SITES_PATH, etc
- Detecting modules and apps by the presence of a sentinel .frappe file
- Site is scoped by frappe.local.site_name (thread safe)
Config handler: (`frappe.bench.sites{,.site}.config`)
- Optional config registry for better discovery; warning if not specced
- Env variable overload with `FRAPPE_` prefix
* chore: type frappe.config
* chore: type frappe.bencher
* chore: py310 compat
* chore(typing): type filters
* chore(typing): type filters for get_list et al
* fix: dashboard chart filter expression
* test: fix case with new-style right hand object to equality check
* chore: place new typed filter under typing verification
* chore: remove debug print statment
* chore: inverse logic of type guard
* fix: add float to filter value types
* chore: clarify value naming
These were implicitly handled due to the catch-all 0.0 return, but type checkers break here, and a lot of places depend on this behaviour
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
* test: fix universal type checker based on downstream use and more testing
* fix: type validation error reporting
* fix: types; various
* chore: switch off test-time type checking
still too many errors