Comments (4)
Hi Yuri, thanks for getting in touch about this!
A few questions:
- (This one out of curiosity): are you actually running into perf trouble with Record freezing, or is this just a random optimization you spotted?
- Have you benchmarked the perf difference? Any idea how much more efficient this'd be?
- Do you have any reference for
.__extmap
being stable despite being undocumented? I'm generally inclined to avoid undocumented behaviour unless it's well established as stable.
An alternative to introspecting this at freeze time would be to allow the client code to register the record as freezable, which would introspect the class and record the list of fields once at registration time.
That's an interesting idea. We could potentially also just cache the initial introspection. BTW have you tried writing a custom freezer for your Record type? That's generally the approach I take when I've got type(s) I'll be repeatedly freezing since it gives you full control over which fields are frozen and how.
Cheers :-)
from nippy.
Sorry about the delayed response.
I was benchmarking the performance of freezing records using the default implementation, and it seemed like the code was spending a substantial amount of time in "into", so then I dived into the implementation of Record freezing and saw it there. My implementation is specific in that it is a fairly large tree of records, and into is called recursively because we recursively freeze records
I haven't benchmarked the performance difference.
I found out about __extmap from this discussion: http://stackoverflow.com/questions/4520319/clojure-assigning-defrecord-fields-from-map
The discussion dates from 2010, and __extmap is still the case today, so it seems stable to me.
I haven't tried writing a custom freezer because I use records as typed maps: I know that I will have some fields on a record, guaranteed, but I also assoc many other key-value pairs that are not declared up front, and I want all of them frozen; in my particular case, if I were indeed to write a custom freezer, it would be exactly the mechanism I outlined to you: freeze the known fields, and then freeze the __extmap; and then I would rewrite the "freeze the known fields" part generically as an introspecter.
from nippy.
No problem, thanks for the detailed follow-up. First step would be to benchmark the difference in freeze+thaw times to see what we're working with, then we can go from there! Cheers :-)
from nippy.
I have avoided solving this problem by decreasing the number of objects that I persist, so this optimization is not really necessary for me anymore.
from nippy.
Related Issues (20)
- Bump encore to 3.49 to avoid "Insufficient com.taoensso/encore version" error in timbre HOT 5
- Support for Clojure CLR? HOT 6
- Upgrade data encryption to use new Tempel lib
- Handling unfreezable data HOT 6
- Possible to create deterministic encryption? HOT 5
- should `extend-freeze` affect `freezable?` HOT 3
- checksum change for serialised output between 3.2.0 and 3.3.0 HOT 5
- JDK 21 benchmarks HOT 8
- Nippy v3.4.0-RC1 HOT 1
- Nippy v3.4.0 final HOT 1
- Question: does Nippy Zstandard support training? HOT 1
- v3.4.0-RC1: zstd cannot be decompressed without specifying the compressor HOT 3
- Support UUID (and inst)? HOT 2
- Nippy doesn't know how to freeze metadata from next.jdbc HOT 16
- Cannot `freeze-to-file` and `thaw-from-file` objects that are larger than 2GB HOT 3
- CVE on tools-reader 1.4.2 HOT 2
- A question about extend-freeze HOT 1
- The with-cache macro is marked private HOT 4
- Reducing the dependency footprint HOT 2
- String array deserialization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nippy.