- Notifications
You must be signed in to change notification settings - Fork1.9k
col-cache: optimize for performance#1489
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lib/utils/col-cache.js Outdated
| // check if value looks like an address | ||
| validateAddress(value){ | ||
| if(!value.match(/^[A-Z]+\d+$/)){ | ||
| // if (!value.match(/^[A-Z]+\d+$/)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
could you please benchmark if your new implementation is faster than this:
constaddressRegex=/^[A-Z]+\d+$/;// ...validateAddress(value){if(!addressRegex.test(value)){thrownewError(`Invalid Address:${value}`);}returntrue;}
This one would be a lot easier to read and maintain :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
npm run benchmark shows thataddressRegex.test is slightly slower, I'll switch to this if you wish.
npm run benchmark on myfreeer:col-cache-performance(8a47ae7) with validateAddress implementation mentioned above
> exceljs@4.1.1 benchmark D:\UserData\projects\exceljs> node --expose-gc benchmark####################################################WARMUP: Current memory usage: 8.87 MBWARMUP: huge xlsx file streams profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsWARMUP: huge xlsx file streams profiling finished in 6090msWARMUP: Current memory usage (before GC): 46.75 MBWARMUP: Current memory usage (after GC): 9.6 MB####################################################RUN 1: huge xlsx file streams profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsRUN 1: huge xlsx file streams profiling finished in 6063msRUN 1: Current memory usage (before GC): 44.24 MBRUN 1: Current memory usage (after GC): 9.75 MB####################################################RUN 2: huge xlsx file streams profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsRUN 2: huge xlsx file streams profiling finished in 5970msRUN 2: Current memory usage (before GC): 67.58 MBRUN 2: Current memory usage (after GC): 9.74 MB####################################################RUN 3: huge xlsx file streams profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsRUN 3: huge xlsx file streams profiling finished in 6220msRUN 3: Current memory usage (before GC): 69.27 MBRUN 3: Current memory usage (after GC): 9.79 MB####################################################WARMUP: Current memory usage: 9.47 MBWARMUP: huge xlsx file async iteration profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsWARMUP: huge xlsx file async iteration profiling finished in 6015msWARMUP: Current memory usage (before GC): 40.56 MBWARMUP: Current memory usage (after GC): 9.83 MB####################################################RUN 1: huge xlsx file async iteration profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsRUN 1: huge xlsx file async iteration profiling finished in 5956msRUN 1: Current memory usage (before GC): 37.71 MBRUN 1: Current memory usage (after GC): 9.82 MB####################################################RUN 2: huge xlsx file async iteration profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsRUN 2: huge xlsx file async iteration profiling finished in 5870msRUN 2: Current memory usage (before GC): 37.96 MBRUN 2: Current memory usage (after GC): 9.85 MB####################################################RUN 3: huge xlsx file async iteration profiling startedReading worksheet 1Reading row 50000Reading row 100000Reading worksheet 2Reading row 150000Processed 2 worksheets and 150002 rowsRUN 3: huge xlsx file async iteration profiling finished in 5902msRUN 3: Current memory usage (before GC): 39.57 MBRUN 3: Current memory usage (after GC): 9.88 MBThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
yeah let's do it - other than that, the PR looks great!
Doing a profiling in chrome dev tools shows that the function decodeAddress and validateAddress in lib/utils/col-cache.js are taking considerable amount of time, mainly on the cache lookup and regexp matching. This would make that faster, especially with large worksheets.
8a47ae7 toe8731f8Compare
alubbe left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
thank you!
Summary
Doing a profiling in chrome dev tools shows that the function
decodeAddressandvalidateAddressinlib/utils/col-cache.jsare taking considerable amount of time, mainly on the cache lookup and regexp matching. This would make that faster, especally with large worksheets.Test plan
Existing unit test and
npm run benchmarkresult below.Env: Windows 10 x64, node.js 12.18.4 LTS x64
npm run benchmark on master(a682091)
npm run benchmark on myfreeer:col-cache-performance(8a47ae7)