Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upRemove usage of String in the asset manager #88
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
OvermindDL1
Sep 6, 2016
Shouldn't most asset strings have the 'key' only allocated once per app? If not then a flyweight string container could do that. That way you get a unique id comparison via taking the pointer of the string or the appropriate method in rust.
OvermindDL1
commented
Sep 6, 2016
|
Shouldn't most asset strings have the 'key' only allocated once per app? If not then a flyweight string container could do that. That way you get a unique id comparison via taking the pointer of the string or the appropriate method in rust. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bjadamson
Sep 6, 2016
Shouldn't most asset strings have the 'key' only allocated once per app?
I agree this is probably true, but it's forcing the user to use a string when they otherwise would not. That's really what I'm trying to point out.
If not then a flyweight string container could do that. That way you get a unique id comparison via taking the pointer of the string or the appropriate method in rust.
This makes sense in the current implementation to me.
bjadamson
commented
Sep 6, 2016
•
I agree this is probably true, but it's forcing the user to use a string when they otherwise would not. That's really what I'm trying to point out.
This makes sense in the current implementation to me. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bjadamson
Sep 7, 2016
Here's a pull request showing what I'm thinking.
Any thoughts? I'd like to audit everything for this change. I'm happy to add some implementation of string based asset-management that's built ontop of this, if that's desired. My real goal is to allow myself a path for not using strings here.
bjadamson
commented
Sep 7, 2016
•
|
Here's a pull request showing what I'm thinking. Any thoughts? I'd like to audit everything for this change. I'm happy to add some implementation of string based asset-management that's built ontop of this, if that's desired. My real goal is to allow myself a path for not using strings here. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Geemili
Sep 7, 2016
Could we make it a generic so that the user can decide?
Another thought I had is making a build script that takes a resource file and bakes the strings into integers, similar to how android does it. The build script could generate a bunch of environment variables like AMETHYST_RESOURCE_ID_sphere_mesh=123. After the environment is generated, the user can just include using:
let sphere_resource = env!("AMETHYST_RESOURCE_ID_sphere_mesh");
Or even a custom macro so we can omit the prefix:
let sphere_resource = resource!("sphere_mesh");
Anyway, those are my thoughts. Don't know if we want to mess with build scripts.
Geemili
commented
Sep 7, 2016
|
Could we make it a generic so that the user can decide? Another thought I had is making a build script that takes a resource file and bakes the strings into integers, similar to how android does it. The build script could generate a bunch of environment variables like
Or even a custom macro so we can omit the prefix:
Anyway, those are my thoughts. Don't know if we want to mess with build scripts. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bjadamson
Sep 7, 2016
I like this, I think I can put a builder in front of this and make it general.
bjadamson
commented
Sep 7, 2016
|
I like this, I think I can put a builder in front of this and make it general. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Geemili
Sep 7, 2016
Another thought: If we're going to deal with build scripts, we could just generate a "resources.rs" that contains all the resource constants. It would mean that all the env!() macros wouldn't need a u32::from_str().unwrap() surrounding them.
Geemili
commented
Sep 7, 2016
|
Another thought: If we're going to deal with build scripts, we could just generate a "resources.rs" that contains all the resource constants. It would mean that all the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Emilgardis
Sep 7, 2016
Contributor
One way to have both i64's and String is to with #90 have each function take id: T where T: Into<*Id>
The one problem I can see are collisions. One way to fix this is to feature-flag i64 to only have one enabled, but I'm playing around trying to find a good solution.
|
One way to have both i64's and String is to with #90 have each function take id: T where T: Into<*Id> |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bjadamson
Sep 7, 2016
Another thought, maybe it makes sense to always support static str& but String explicitly separately?
bjadamson
commented
Sep 7, 2016
•
|
Another thought, maybe it makes sense to always support static str& but String explicitly separately? |
ebkalderon
added
type: improvement
note: help wanted
diff: easy
status: in-progress
pri: normal
and removed
status: in-progress
labels
Sep 7, 2016
ebkalderon
added this to the 1.0 milestone
Sep 14, 2016
bjadamson
referenced this issue
Oct 12, 2016
Closed
Concerns regarding performance throughout framework, future goals #117
ebkalderon
added this to In Progress
in Engine
Feb 3, 2017
ebkalderon
moved this from In Progress
to Blocked
in Engine
Feb 3, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ebkalderon
Feb 3, 2017
Member
The asset manager has changed significantly since the creation of this issue and uses &str as opposed to fat strings. I think I'll close this issue as it is no longer relevant.
|
The asset manager has changed significantly since the creation of this issue and uses |
bjadamson commentedSep 6, 2016
Looking up resources by a string is convenient but slow thanks to dynamic allocation. I believe this is why OpenGL uses integer handles, even if it they are less convenient to work with.
These string should be replaced with type-safe integer wrappers, or some other design to improve the performance of the asset manager.
https://github.com/amethyst/amethyst/blob/develop/src/context/src/asset_manager.rs#L41-L42
Consideration must be given to the current convenience though, especially if it is removed.
Maybe offering both versions make sense? What does everyone think?