-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: AutoForm performance? #70
Comments
cc @radekmie I've in fact experienced this issue as well. My solution was
to break the form down into smaller forms and handle the individual pieces
of data but my usecase did allow for that so it may not be generally
applicable.
|
@serkandurusoy - even if you have a single form with a single array field, in my example once the When you say "handle the individual pieces of data," do you mean that you stopped using |
To be honest, I was pretty sure, that I will release As of #31, there's <AutoFields fields={['name', 'categories']} /> |
Thanks @radekmie for the quick response. I'm still getting up to speed with the library (which otherwise seems excellent by the way), so do you have any advice for a temporary workaround? I don't need real-time validation, for example; validating onSubmit would be fine with me -- is there any way I can disable real-time validation and achieve better performance that way? |
By default, <AutoForm validate="onSubmit" schema={...} onSubmit={...} /> (okay, it's not well documented, but it's on this diagram) |
Thanks, I did try that earlier, but it didn't have the expected impact on performance. |
Well, that means, that validation is not a problem. |
@mdorn I do use autoform as is but in all fairness, my usecase did not include array fields that would grow too big and it was mainly used as an update form, so I was able to split to big form into small forms which dealt with relevant parts of the docuement. Something like, a form updates user's name and age, another form updates the address, another updates some other profile field, they are all autosave so there's no button involved, which in turn creates the perception of a single profile edit form. but yeah, performance is an issue :( |
I've played a little with @mdorn, @serkandurusoy Note: This depends on some (maybe incorrect) assumes, like label or placeholder won't change without value change. |
@radekmie - thanks for the quick turnaround on this. Subjectively (without doing any real profiling, etc. -- I'm still pretty new to React and Meteor), it does seem a bit faster. However in the conditions I describe (1 String field and 10+ text boxes on the screen as part of a single Array field), typing in one of the text boxes continues to feel quite sluggish. If a fast typist (e.g. 90 words per minute) types a sentence of 140 characters or so, it may take 2-3 seconds to see all of the words in the input box. This is true even if I remove any Array fields so that I've not tried it on multiple computers yet -- FWIW here are the specs of the computer I'm working on:
|
Another optimization done. @mdorn |
@radekmie here's a schema where we had problem with Especially the arrays were problematic, for example contact emails! In fact, even after separating the schema into smaller schemas in individual forms, the contact emails schema on its own, when used with autoform, becomes really slow after adding a few emails into the array Meteor.users.masterProfile.schema = new SimpleSchema({
userId: {
type: String,
index: 1,
unique: true,
regEx: SimpleSchema.RegEx.Id,
},
accountEdited: {
type: Boolean,
defaultValue: false,
},
'name.first': {
type: String,
max: 256,
},
'name.last': {
type: String,
max: 256,
},
'organization.name': {
type: String,
max: 256,
optional: true,
},
'organization.role': {
type: String,
max: 256,
optional: true,
},
slug: {
type: String,
index: 1,
unique: true,
denyUpdate: true,
autoValue: function() {
const first = this.field('name.first');
const last = this.field('name.last');
if (this.isInsert) {
if (first.isSet && last.isSet) {
const userSlug = slugify(`${first.value} ${last.value}`);
const usersCount = parseInt(Meteor.users.masterProfile.find({ slug: userSlug }).count());
return `${userSlug}${usersCount > 0 ? '-' + usersCount + 1 : ''}`;
}
} else {
this.unset();
}
}
},
avatarUrl: {
type: String,
optional: true,
},
birthDay: {
type: Date,
optional: true,
},
contactEmails: {
type: [Object],
optional: true,
custom: function() {
if (this.isSet) {
if (this.value.length !== _.uniq(_.pluck(this.value, 'address')).length) {
return 'notUnique';
}
}
},
},
'contactEmails.$.address': {
type: String,
optional: true,
regEx: SimpleSchema.RegEx.Email,
},
'timeZone.identifier': {
type: String,
allowedValues: TIME_ZONE,
},
'timeZone.setManually': {
type: Boolean,
defaultValue: false,
},
'phones.$.countryDialCode': {
type: String,
allowedValues: DIAL_CODE,
optional: true,
},
'phones.$.number': {
type: String,
max: 256,
optional: true,
},
'address.street': {
type: String,
max: 256,
optional: true,
},
'address.city': {
type: String,
max: 256,
optional: true,
},
'address.zipCode': {
type: String,
max: 256,
optional: true,
},
'address.country': {
type: String,
allowedValues: _.pluck(COUNTRY, 'name'),
optional: true,
},
'siteLinks.$.name': {
type: String,
max: 256,
optional: true,
},
'siteLinks.$.url': {
type: String,
regEx: SimpleSchema.RegEx.Url,
optional: true,
},
'socialLinks.facebook': {
type: String,
regEx: SimpleSchema.RegEx.Url,
optional: true,
},
'socialLinks.linkedIn': {
label: 'LinkedIn',
type: String,
regEx: SimpleSchema.RegEx.Url,
optional: true,
},
'socialLinks.twitter': {
type: String,
regEx: SimpleSchema.RegEx.Url,
optional: true,
},
'socialLinks.googlePlus': {
type: String,
regEx: SimpleSchema.RegEx.Url,
optional: true,
},
}) |
Okay, thanks - I'll play with it. |
@radekmie nice work on optimizations - let us know how the hunt for performance increases goes |
I've just released Further optimizations are planned, but current version is good enough (for me of course) - now I want to close few more issues and finally release I'll close this issue, as the main problem with CPU intensive forms is solved - don't worry, more optimizations are coming. |
FTW!!! On Mon, Jul 18, 2016, 3:32 PM Radosław Miernik notifications@github.com
|
Thanks @radekmie -- HUGE improvement! Large numbers of items rendered as |
I'm using
AutoForm
with minimal configuration on a Simple Schema that contains about 10 fields (mostly text fields, but one is an object that populates about 12 select boxes). I'm usingAutoField
for all of them. I've noticed that when I type in one of the text boxes, there's a very noticeable lag, and the CPU usage on my computer spikes significantly.As I've experimented, I've noticed that any time there's more than 8 or 10 fields on the form, performance suffers badly.
Is there anything that I can do to help this situation besides not using
AutoForm
?I've actually cobbled together a simple test form that reproduces the problem: if I add 10 items to "categories" using the form below, typing into the "name" field becomes very slow and CPU-intensive:
The text was updated successfully, but these errors were encountered: