Skip to content

Conversation

@dmlloyd
Copy link
Member

@dmlloyd dmlloyd commented Nov 19, 2025

When accepting Class<?> arguments, try to avoid hitting the slow synchronized map behind ClassValue for common types. The common types are gleaned from our known constant fields. We're trading a bit of class init time for higher throughput. An alternative would be to hand-write the map, which is a little more error-prone but could possibly be faster than using reflection.

When accepting `Class<?>` arguments, try to avoid hitting the slow synchronized map behind `ClassValue` for common types.
The common types are gleaned from our known constant fields.
We're trading a bit of class init time for higher throughput.
An alternative would be to hand-write the map, which is a little more error-prone but could possibly be faster than using reflection.
@dmlloyd
Copy link
Member Author

dmlloyd commented Nov 19, 2025

Another possible follow-on or substitute idea would be to make this map be copy-on-write, and add in entries for any class which is in the application, platform, or boot class loaders (since those will never unload anyway, they cannot leak).

@dmlloyd dmlloyd added the 2.x Issue applies to Gizmo 2.x label Nov 19, 2025
@gsmet
Copy link
Member

gsmet commented Nov 19, 2025

Have you measured any diff, I don't see any in the crazybeans benchmark? Now, maybe it's not testing a scenario where this could shine?

@dmlloyd
Copy link
Member Author

dmlloyd commented Nov 19, 2025

I think the crazybeans paths mostly use descriptor constants now, so it might not be the best test for this. But then again maybe that shows that this change won't really help much in practice.

@Ladicek
Copy link
Member

Ladicek commented Nov 20, 2025

Unless someone sneaked a change into ArC that I'm not aware of, the crazybeans benchmark still uses a lot of .class constants in ArC itself. Personally, I consider using class constants idiomatic and would be against moving to class descriptors.

@dmlloyd dmlloyd marked this pull request as draft November 24, 2025 18:52
@dmlloyd
Copy link
Member Author

dmlloyd commented Nov 24, 2025

I want to ponder this a bit more and see if I can make it have a measurable performance benefit in some form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.x Issue applies to Gizmo 2.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants