jesspav commented on code in PR #446:
URL: https://github.com/apache/sedona-db/pull/446#discussion_r2617190761
##########
rust/sedona-schema/src/crs.rs:
##########
@@ -15,41 +15,61 @@
// specific language governing permissions and limitations
// under the License.
use datafusion_common::{DataFusionError, Result};
+use lru::LruCache;
use std::fmt::{Debug, Display};
+use std::num::NonZeroUsize;
use std::str::FromStr;
use std::sync::Arc;
+use std::sync::Mutex;
+use std::sync::OnceLock;
use serde_json::Value;
+/// LRU cache for CRS deserialization
+static CRS_CACHE: OnceLock<Mutex<LruCache<String, Crs>>> = OnceLock::new();
+
+fn get_crs_cache() -> &'static Mutex<LruCache<String, Crs>> {
+ CRS_CACHE.get_or_init(|| {
+ // Cache up to 256 CRS strings
+ Mutex::new(LruCache::new(NonZeroUsize::new(256).unwrap()))
+ })
+}
Review Comment:
Yes!!! That should have an impact on the perf of a single thread, too, since
it avoids the lock.
any opinion on the magic number for size of the cache? this could get very
large if all the keys are json!!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]